Search code examples
javascriptjqueryjquery-mobilejquery-events

jquerymobile how to bind and unbind a link?


In my mobilejquery project, I need to unbind the links (hrefs), and bind them a point, for that, I use this code:

$(document).bind('pageinit', function () {

    $('a[href="#"], a.disabled').bind('click',function (e) {
        e.preventDefault();    //sets all dynamic href to prevents wrong url
    } )
});

but not at all works... anything wrong with my code?

Additional question..

I don't want to show the url path in the navigator.. is there any way to make the url path not to show?


Solution

  • did you try using the unbind() method?

    $('a[href="#"], a.disabled').unbind("click").bind('click',function (e) {
       e.preventDefault();    //sets all dynamic href to prevents wrong url
    } )