tags:

views:

33

answers:

2

My url is of the format http://www.xyz.com/DisplayPost.php?postid=200

I want to detect if the url has "postid=250" in it and hide a div called divOne

How can I do it using jQuery

+1  A: 

The query string is stored in the window.location.search variable, so you can scan that:

/[?&]postid=250(&|$)/.test(window.location.search)
nickf
where did the other reply go??Nick, I want to start by hiding the div and then display it only when postid is not equal to 250. Should I set visibility:hidden or visibility:collapse and howto change the logic
ScG
Another point is that the content of the div gets populated with a script. It's basically an advertisement that shows up using javascript
ScG
A: 

I suspect you might be going about this the hard way. Why not just have the empty, which can be effectively the same thing as invisible, then just let it show when it is populated by the script?

Ray