jquery rule for href with # only
How to apply a rule on a class .button that have a href of "#" only
in fact, any button with a real href will do 开发者_开发技巧his button thing, the other one, onother thing
just to clear thing
$(".jbutton").click( function () {
i like that function to be executed on anything BUT #... exclude #
is it more clear ?
Live Demo
http://jsfiddle.net/Jaybles/nEdHH/
HTML
<button href="#" id="button0"></button>
<button href="123" id="button1"></button>
<button href="123" id="button2"></button>
JS
$('button[href!="#"]').click(function(){
alert($(this).attr('id'));
});
You should use attribute selectors:
$('a[href!="#"].button').click(...)
$(".jbutton[href='#']").click(...
精彩评论