javascript - JQuery .click(function(){}) works locally but not on the server -
i confused. piece of code works fine should on local server on computer. after uploaded hostgator server, function not being executed anymore, since when set break point on firefox debugger, function not called when clicked on class called deck-title
. yet locally, break point work , function called.
// when click decks, current deck should change $(document).ready(function() { $(".deck-title").click(function() { var decktitle = $(this).text(); $("#current-deck-span").html(decktitle); if (decktitle !== current_deck_global) { var deckid = getdeckidfromtitle(decktitle); updatedisplayingdeck(current_userid, deckid); } current_deck_global = $(this).text(); }); });
any ideas on click(function()
? mean, every other jquery code worked fine on hostgator server, except one...
here <head>
in web page:
<head> <title></title> <meta charset="utf-8"></meta> <link href="./css/home.css" type="text/css" rel="stylesheet"></link> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> </head>
i loading jquery script first before other script. $(document).ready(function())
should work (i checked giving every css element border after document ready, , yea, borders shown.
i appreciate help! thanks!
it seems handler running early. try using event delegation:
$(document).on("click", ".deck-title", function() { //..... });
Comments
Post a Comment