Your problem is twofold.
1) change $(this) to this $('body') (assuming that the text will only appear
within the body tag.
2) Your replace might be working, but it's only acting upon the string
within your temp variable. You'd really need to break the second line into
two parts like so:
var regexp = /([a-zA-Z]+\.[a-zA-Z]+)/;
var replaced = $('body').html().replace(regexp,'&someURLVar=someValue');
$('body').html(replaced);
-----Original Message-----
From: Will Tomlinson [mailto:[email protected]]
Sent: Wednesday, February 17, 2010 2:49 PM
To: cf-talk
Subject: jquery find/replace on an entire body DOM
I didn't get any response on the jquery list, so I'm reposting this here.
Hey,
I need to traverse an entire DOM, find a match for a pattern like this:
someController.somemapping
And I need to replace that text with this:
someController.somemapping&someURLVar=someValue
This pattern could be located ANYwhere inside the body of the document - a
form action, an onclick, etc.
Here's what I've built so far, but it doesn't work. Any ideas would be
appreciated:
$(document).ready(function() {
var regexp = /([a-zA-Z]+\.[a-zA-Z]+)/;
$(this).html().replace(regexp,$1 + "&someURLVar=someValue"); });
Thanks, Will
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know
on the House of Fusion mailing lists
Archive:
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:330840
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4