hi
i have two div with same class name.these two div are generated dynamically by javascript from different server, so i dont have access to css file. i want hide one div when page load. so how to acess the div.
regards
rajan
hi
i have two div with same class name.these two div are generated dynamically by javascript from different server, so i dont have access to css file. i want hide one div when page load. so how to acess the div.
regards
rajan
I assume that you have to use a
js script for this as php can't affect the divs as they don't exist until after the data has left the server.
You can use jQuery's $('document').ready() to alter the div classes or apply an inline style/css attribute, e.g. style="display:none;" or $('.classname').css("display","none");
Of course, as you'll guess, you have to reference the first or second of the two divs as they have the same class. If they have ids, you could reference them directly like that, e.g. $('#idname').css("display","none");
If not, say it's only the first div:
$(".classname:first").css("display", "none");
or for last:
$(".classname:last").css("display", "none");
You can then use
$(".classname:last").css("display", "");
to show the div - link this to an event, e.g. click.
Anyway, I'm a duffer at js/jQuery, so you may get a better response over at the js forum.
Yeah, nothing to do with PHP...
Moving to JS.
In jQuery, you can address the two divs collectively as follows:
$("div.myclassname").hide();
Or individually as follows:
$("div.myclassname").eq(0).hide(); //first div
$("div.myclassname").eq(1).hide(); //second div
//etc.
In these examples, the div(s) are hidden. For some other action, change hide()
.
Airshow
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.