supposed we have
<a href=# id="5"> hello world </a>
to get the value of id
$('a').each(function(){alert(this.id);});
//5
Category: jquery
jQuery, check if element exists
if($('#some-div').length)){ /* exists */}
jquery click() doesn’t work after dom update on ajax call.
<a class="clickme" href=#>clickme</a>
$('a.clickme').click(function(){ alert('hello')});
only work on DOM that already exists. it is not working.if the html above injected on existing DOM.
in this case you have to use.
$('a.clickme').live('click', function(){alert('hello')});
jquery click li to activate a
<ul class="menu">
<li><a href="/"> Home </a></li>
</ul>
to activate the link when user click on li
$('.menu li').click(function(e){
location.href = $(this).find('a').attr('href');
});
Now, user doesn’t have to click on the “Home” to activate the link.
jquery open new window on external links
$("a:not([href^='http://www.exampleuri.com']): not([href^='#']):not([href^='/'])").attr("target","_blank");
fix Firefox 3 & jquery bug
It is the problem when the $(document).ready() executed before the CSS loaded.
Make sure all CSS come before the scripts
<script type="text/javascript" src="">
<link rel="stylesheet" type="text/css" href="">
to
<link rel="stylesheet" type="text/css" href="">
<script type="text/javascript" src="">
FCKEditor the easy way
fckeditor not that hard to install, but you may need some time to figure it out. Life is easier if you use FCKeditor jQuery way
alternate table row color. the easy way!
it is very simple using jQuery.
$(document).ready(function() {
$('table.zebra tr:odd').addClass('odd');
$('table.zebra tr:even').addClass('even');
});
of course you have to create two css class with the name even and odd.