// there are rumblings of romoving the event shortcuts (eg $().change) // not sure if change works on a checkbox, if not click should work $('#sendAlert').bind("change",function(){ // find all links in #panel and apply a function to each one $("#panel a").each(function(){ // within each 'this' refers to the element object // not sure if the regex is right this.href=this.href.replace(/&sendAlert=[\d]+/,"&sendAlert="+( this.checked?"1":"0")); }); });
Blair On 12/13/06, Robert James <[EMAIL PROTECTED]> wrote:
I'd like to use JQuery to hook up a check box to flip a URL param in a bunch of hrefs. The href would either be 'http://myapp/do/this?id=3&sendAlert=1' or http://myapp/do/this?id=3&sendAlert=0' Something like: $('#sendAlert').change(function() { sendAlert = (this.checked ? '1' : '0') ; $('#panel a').href.removeTheSendAlert - not sure how to do this $('#panel a').href.append('&sendAlert=' + sendAlert); The two problems I'm having are: 1. What is the code to remove the old param of sendAlert (you can assume that it's at the end)? 2. How do I use JQuery to manipulate hrefs? _______________________________________________ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
_______________________________________________ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/