jquery quick tips to replace javascript code from file learn jquery
The jquery is a simple and quick to use javascript library and provides a
rich set of functionality in just few lines of code.The $ symbol is also set up as
a shortcut for jQuery.If you want the convenience of the $ function for jQuery without colliding with some other use of the global $ function, the jQuery documentation suggests the following idiom:
(function($) {
// Within this block, $ is a reference to jQuery
// Neat, and clean
})(jQuery);
Referring elements of document in jquery code.
jQuery(’div.panel’)
All divs with class=“panel”
jQuery(’p#intro’)
The paragraph with id=“intro”
jQuery(’div#content a:visible’)
All visible links inside the div with id=“content”
jQuery(’input[@name=email]‘)
All input fields with name=“email”
jQuery(’table.orders tr:odd’)
“odd” numbered rows in a table with class “orders”
jQuery(’a[@href^="http://"]‘)
All external links (links that start with http://)
jQuery(’p[a]‘)
All paragraphs that contain one or more links if (t.val() == title) {
t.val(”);
t.removeClass(‘blur’);
$(‘input:text‘).hint();
var title = t.attr(‘title’); // only apply logic if the element has the attribute if (title) { // on blur, set value to title attr if text is blank t.blur(function (){ if (t.val() == ”) { t.val(title); t.addClass(‘blur’); } }); // on focus, set value to blank if current value // matches title attr t.focus(function (){ if (t.val() == title) { t.val(”); t.removeClass(‘blur’); } });t.parents(‘form:first()’).submit(function(){ if (t.val() == title) { t.val(”); t.removeClass(‘blur’); } })$(‘#search, #username, input.hint’).hint(); // etc
<!--adsensestart-->


Discussion Area - Leave a Comment
You must be logged in to post a comment.