Jump to content

jaikiran

Members
  • Posts

    4
  • Joined

  • Last visited

jaikiran's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. The following works in FireFox, but not in IE: <html><head><style>select[disabled] {color:red!important;}</style><script type="text/javascript">function changeMyCol(){var s = document.getElementById("s1")s.disabled="true"}</script></head><body ><select id="s1" > <option id="o1">Colour1</option> <option id="o2">Colour2</option></select><p><input type="button" id="b1" value="Click me to disable and change colour" onClick="changeMyCol()"/></body></html>
  2. Fantastic, that works great. Thanks a lot, scott100
  3. Thank you, scott100. Got your point. I have few question though:1) In the mouseOut() function, the implement that you suggest, would require the mouseOut() method to have a knowledge about which object is enclosed in the anchor tag(in this case the img object). What if i want to make the mouseOut() method generic i.e. irrespective of which object is enclosed in the anchor tag, i would like to swap it will the string 'hi' and the originally enclosed object, on every mouseout and mouseover event. Is this possible? The reason for maintaining the global variable 'myv' was to achieve this purpose.2) For a moment, lets forget about my question#1 above. One more thing that surprised me in the javascript code that i posted as part of my first post in this topic, is that if you uncomment the alert and watch the value of 'myv' variable, it is pointing to the img object just before *leaving* the mouseover() method. But, when *entering* the mouseout() method, the value of the same variable changes to 'hi'. How does this value get changed between these calls?
  4. Hi, I am new to javascript and just tried out a few examples provided on w3 schools javascript section. One of them was the Button Animationexample. I did a slight modification to this example. Here's what i am trying to achieve:- onMouseOver of the anchor tag, i am replacing the image with a string(using innerHTML of the anchor tag). While doing this, i maintain the image object in a global variable - onMouseOut of the anchor tag, i am trying to restore back the image by using the contents of the global variable.I am able to do the replace the image with the string in onMouseOver, however onMouseOut, i am not able to restore it back.Here's the code: <html><head><script type="text/javascript">var myvfunction mouseOver(){myv=document.getElementById("mya").innerHTML//alert("Before replacing innerHTML is: " + myv)document.getElementById("mya").innerHTML="Hi"//alert("After replacing, obj is: " + myv)}function mouseOut(){//alert("Before assigning in moveout, obj is: " + myv)document.getElementById("mya").innerHTML=myv}</script></head><body><a id="mya" href="http://www.w3schools.com" target="_blank"onmouseover="mouseOver()"onmouseout="mouseOut()"><img border="0" alt="Visit W3Schools!" src="b_pink.gif" name="b1" width="26" height="26" /></a></body></html> I have commented out the alerts. Please uncomment them if required. Whats baffling me is that at the end of the mouseOver() method, i print the contents of the global variabl 'myv' which correctly points to the image object. But, on entering the mouseOut() method, when i print the contents of the same, the contents have surprising changed to the string 'hi'.Any idea, whats wrong here?
×
×
  • Create New...