How to exclude some div form body for replace

I want to replace some content with JQuery function replace(), like this...

...
var content = $("body");
content.html(content.html().replace(/([a-zA-Z])[']([a-zA-Z])/g,'$1’$2'));
...

However, I want to exclude some div, like "#foo" or "#bar".

I try...

var content = $("body") > *:not("#bar");
...
var content = $("body").find(":not(#bar)");
...

but it doesn't work.

The only solution that works with me is to list one by one each div where to apply the expected replacement. This solution seems poor! :)

Thanks a lot for your help!

Cheers,

Vincent

Answers


Try this:

var content = $("body:not('#bar')");

Or using not() method:

var content = $("body").not('#bar');

Need Your Help

render cms page within another page

python django placeholder django-cms

Im trying to render a cms page, within another page using a custom cms plugin.

How to control :selected for collection_select?

ruby-on-rails ruby ruby-on-rails-3 forms

Currently if you call @team.user_ids it returns "1,3,7" as opposed to [1,3,7]. I need it to be like that for other reasons, but it's breaking the front-end collection_select. I've tested and it works

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.