How to use jquery query string object plugin - set, empty, remove methods not working

丶灬走出姿态 提交于 2019-12-11 00:15:06

问题


I am using this plugin: http://plugins.jquery.com/project/query-object

The 'get' and 'toString' methods work fine, but the 'set', 'empty', and 'remove' methods do not work. In the author's demonstration, he only uses 'get' and 'toString', but in his example on the top of the page, he uses the rest of the "nice-to-have" methods.

Anyone run into this before?

Thanks.


回答1:


I tried the set method, and it works just fine:

alert($.query.set("section", 5).set("action", "do").toString());

Output:

?section=5&action=do



回答2:


Functions like .set return modified copy of original query-object. If you wish to modify existing object (for example one created using .load(string) method), use .SET method. Modifying of query string is possible now using HTML5: search for window.history.pushState(). Setting window.location.href variable will result in reloading page.



来源:https://stackoverflow.com/questions/2906141/how-to-use-jquery-query-string-object-plugin-set-empty-remove-methods-not-wo

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