queness hat einige jQuery Tips and Tricks gesammelt.
Einige Beispiele:
Make the entire LI clickable
$("ul li").click(function(){
//get the url from href attribute and launch the url
window.location=$(this).find("a").attr("href"); return false;
});
<ul>
<li><a href="home">home</a></li>
<li><a href="home">about</a></li>
<li><a href="home">contact</a></li>
</ul>
Disable right click
$(document).bind("contextmenu",function(e){
//you can enter your code here, e.g a menu list
//cancel the default context menu
return false;
});
Write our own selector
//extend the jQuery functionality
$.extend($.expr[':'], {
//name of your special selector
moreThanAThousand : function (a){
//Matching element
return parseInt($(a).html()) > 1000;
}
});
$(document).ready(function() {
$('td:moreThanAThousand').css('background-color', '#ff0000');
});
<table>
<tbody>
<tr><td>1400</td><td>700</td><td>400</td></tr>
<tr><td>2500</td><td>600</td><td>100</td></tr>
<tr><td>100</td><td>1100</td><td>900</td></tr>
<tr><td>2600</td><td>1100</td><td>1200</td></tr>
</tbody>
</table>