get head content of page with jquery
by Unknown in javascript , jquery 0
You can use this code:
With Jquery
$("head")
//for example:
alert($("head").html());
With JS:
var headContent = document.getElementsByTagName("head")[0].innerHTML;
by Unknown in javascript , jquery 0
You can use this code:
With Jquery
$("head")
//for example:
alert($("head").html());
var headContent = document.getElementsByTagName("head")[0].innerHTML;
<div id="content"> <h1>Headline</h1> <p>First paragraph that needs to be yellow.</p> <p>Second paragraph that need not change. :) </p> <p>Third paragraph that need not change. :) </p> </div>
by Unknown in javascript , jquery , Tutorial 0
var str = document.getElementById('mydiv').innerHTML; document.getElementById('mytextarea').innerHTML = str.replace(/<br\s*[\/]?>/gi, "\n");
var str = $("#mydiv").html(); var regex = /<br\s*[\/]?>/gi; $("#mydiv").html(str.replace(regex, "\n"));
by Unknown in javascript , jquery 0
$("#theSelect").change(function(){ var value = $(this).val(); if (value === '') return; var theDiv = $(".is" + value); var option = $("option[value='" + value + "']", this); option.attr("disabled","disabled"); theDiv.slideDown().removeClass("hidden"); theDiv.find('a').data("option",option); }); $("div a.remove").click(function () { $(this).parent().slideUp(function() { $(this).addClass("hidden"); }); $(this).data("option").removeAttr('disabled'); });
by Unknown in javascript , jquery 0
$('form').bind("keypress", function(e) { if (e.keyCode == 13) { e.preventDefault(); return false; } });
$("form :input").on("keypress", function(e) { return e.keyCode != 13; });
A beauty drop down responsive menu that shows its sub menus with icon
symbol using open symbol fonts that allowing you to add more icons as
you want. With my previous tutorial, i also show how to create Creating 3-Level Responsive Drop Down Navigation Menu with jQuery and CSS3 as well.
Today we would like to show an experimental drop-down menu with
jquery and css3 using beautiful symbol fonts. The main idea is to help
you to save time for creating menus for website, it have a lot of
content and sub-levels. Some sub-level in this menu will be shown in its
context and icons. The menu is best use in professional web design that
it can be used easily in a responsive layout.
This Responsive Drop Down Navigation Menu using plugin such as:
by Unknown in Brighten Up , jquery 0
Today we are going to use jQuery and CSS3 rotations, along with the jQuery rotate plugin,
to create a beautiful slideshow. You can use it to spice up your web
sites, product pages and other projects with some CSS3 magic.
by Unknown in Brighten Up , css3 , jquery 0
In this tutorial we will see how to create a simple multi-step signup
form using CSS3 and jQuery. To spice up things a bit, we will include
progress bar with the form, so the users will be able to see the
percentage of form completion.
You can take a look at the working demo if you click on the image below:
by Unknown in Brighten Up , css3 , jquery 0
The following tutorial and the demo works best on Chrome and Safari,
correctly on Firefox and very badly in Internet Explorer (eh…I’m sure
you hadn’t guessed that).
jQuery's highlight method will highlight any div with a yellow background.
How do I specify what color to use instead of yellow for highlight?
Answer:
$(this).effect("highlight", {color: 'blue'}, 3000);
<input name="mytest" type="checkbox" value="1"> <input name="mytest" type="checkbox" value="2"> <input name="mytest" type="checkbox" value="3"> <input name="mytest" type="checkbox" value="4">You can do this:
$("input[name='mytest']").val([1, 2, 3]);....which will check the first 3 boxes.
$("img").attr("src", "http://cdn.css-tricks.com/images/banner.jpg");
$("div").attr("id", function (arr) {
return "div-id" + arr;
})
$("img").attr({
src: "http://cdn.css-tricks.com/images/banner.jpg",
title: "banner",
alt: "banner"
});
var $source = $("img").attr("src");
window.load can fire super duper fast if the page is cached. If you want to use that event but make sure a minimum amount of time has passed until it does...
(function fn() {
fn.now = +new Date;
$(window).load(function() {
if (+new Date - fn.now < 500) setTimeout(fn, 500);
// Do something
});
})();
This snippet presupposed an HTML form with and ID of "age-form" and three inputs (text or select) with the IDs "day", "month", and "year" respectively.
$("#age-form").submit(function(){
var day = $("#day").val();
var month = $("#month").val();
var year = $("#year").val();
var age = 18;
var mydate = new Date();
mydate.setFullYear(year, month-1, day);
var currdate = new Date();
currdate.setFullYear(currdate.getFullYear() - age);
if ((currdate - mydate) < 0){
alert("Sorry, only persons over the age of " + age + " may enter this site");
return false;
}
return true;
});
You may wish to do something more elegant than an alert, and should also probably validate the form with server side code or else this protection only works for users with JavaScript enabled.
There is no CSS for applying an underline (text-decoration: underline;
) only to individual words in a multiple-word element. The best way would be to wrap each word in a span (not the spaces, just the words) in spans and apply underline to those spans. Here's jQuery to do that to h1
elements.
$('h1').each(function() {
var words = $(this).text().split(' ');
$(this).empty().html(function() {
for (i = 0; i < words.length; i++) {
if (i == 0) {
$(this).append('<span>' + words[i] + '</span>');
} else {
$(this).append(' <span>' + words[i] + '</span>');
}
}
});
});
Then you could do:
h1 span {
text-decoration: underline;
}
Similar and slightly more robust solution: Lettering.js
$.event.special.tripleclick = {
setup: function(data, namespaces) {
var elem = this, $elem = jQuery(elem);
$elem.bind('click', jQuery.event.special.tripleclick.handler);
},
teardown: function(namespaces) {
var elem = this, $elem = jQuery(elem);
$elem.unbind('click', jQuery.event.special.tripleclick.handler)
},
handler: function(event) {
var elem = this, $elem = jQuery(elem), clicks = $elem.data('clicks') || 0;
clicks += 1;
if ( clicks === 3 ) {
clicks = 0;
// set event type to "tripleclick"
event.type = "tripleclick";
// let jQuery handle the triggering of "tripleclick" event handlers
jQuery.event.handle.apply(this, arguments)
}
$elem.data('clicks', clicks);
}
};
$("#whatever").bind("tripleclick", function() {
// do something
}