I have been trying to create a code like this:
If you show 'us.gif' in the div id 'yourCountry', display this css code: --- #yourCountry img{display:none} --- End of the if
I have tried to do it and searched about it on the web, but nothing has worked for me.
This is how I was attempting to achieve it with javascript (I am a newbie with javascript):
<script language=javascript>
<!--
function usimage () {
if document.images["us.gif"] {
document.write("
<style type="text/css">
<!--
body div div div div div div div div form div div div table td img{display:none;}
-->
</style>
");}}
</script>
JS有点混乱,可以接受CSS 2.1选择器吗?
div#yourCountry img[src="us.gif"] { display:none; }
You can try:
<script language=javascript>
function usimage () {
for(var i = 0; i < document.images.length; ++i)
{
if(document.images[i].src.search("us.gif") >= 0)
{
document.write('<style type="text/css">'
+'<!--'
+'body div div div div div div div div form div div div table td img{display:none;} '
+'-->'
+'</style>'
);
}
}
}
</script>
P/S: You don't understand clearly about js language. Your code is wrong so much like you don't know any language.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.