1 Replies - 458 Views - Last Post: 27 September 2012 - 12:01 PM

#1 tony777  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 27-September 12

jquery block some li tags

Posted 27 September 2012 - 10:18 AM

sorry for my maybe not perfect english but i would try do my best to explain my bag
after puting this jquery code my oher li tags(menu in head) stop working so i wonder why. They have another class but they don't work so i clicking them and nothing happen
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
	<script>
		$(function() {
			$("li").click(function(e) {
			  e.preventDefault();
			  $("li").removeClass("selected");
			  $(this).addClass("selected");
			});
		});
	</script>
	<ul class="tabrow">// this example works fine
	    <li><a href="#">tab1</a></li>
	    <li><a href="#">tab2</a></li>
	    <li class="selected"><a href="#">tab3</a></li>
	</ul>




Is This A Good Question/Topic? 0
  • +

Replies To: jquery block some li tags

#2 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3390
  • View blog
  • Posts: 9,586
  • Joined: 08-June 10

Re: jquery block some li tags

Posted 27 September 2012 - 12:01 PM

Iíd say since you attach that event handler to all <li> (even those in the other menu) and you prevent the eventís default action (of all those <li>), then any links in the other menu cannot work.

If you donít need the <a> in this menu, just omit them. you can style the cursor with CSS, if you want (and then you donít need line #5 either).
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1