javascript - jquery simple onclick event -
<a aria-expanded="false" data-toggle="tab" href="#pictures"> <i class="pink ace-icon fa fa-gift bigger-120"></i> pictures </a>
i want wire on click #picture event alert message add
$(document.ready(function() { $("#pictures").click(function(){ alert('clicked!'); }); })
but doesnt work, i've got no error messages inside firebug console. jquery loaded before correctly.
in html there no element id pictures
, change it,
$("#pictures").click(function(){ alert('clicked!'); }); // or use selector this, if can't change html $('a[href="#pictures"').click(function(){ alert('clicked!'); });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <a aria-expanded="false" data-toggle="tab" href="#pictures" id="pictures"> <i class="pink ace-icon fa fa-gift bigger-120"></i> pictures </a>
update:
also have error in line
$(document.ready(function() {
change it
$(function() { // put code });
Comments
Post a Comment