getting url values in jquery mobile?

耗尽温柔 提交于 2019-12-10 11:29:33

问题


i am trying to get the value attached in the url using jquery mobile.

http://localhost/testing/nothing.html#details?id=0&color=blue

I want to get the id = 0 and color = blue using jquery mobile when i go to the "details" page:

$('#details').live('pagecreate',function(event) {

});

Thanks.


回答1:


Please check this link

Write the fucnction like shown below

$.urlParam = function(name){
var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
return results[1] || 0;

}

To get a particular value just call the function and pass the name of the parameter

    $.urlParam('id'); 


来源:https://stackoverflow.com/questions/7075582/getting-url-values-in-jquery-mobile

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!