Jump to content

selectors issue


manix

Recommended Posts

Actually, it is a question for the Javascript forum, but it is done like this:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xHTML">
    <head>
    <title>Demo</title>
<script type="text/javascript">
function setColor()
{
    document.getElementById('inputDiv').style.background="yellow"
}

function resetColor()
{
    document.getElementById('inputDiv').style.background="white"
}
</script>
</head>
<body>

<form action="">
    <div id="inputDiv" style="padding:10px;">
        <input onfocus="setColor()" onblur="resetColor()" />
    </div>
</form>

</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/249639-selectors-issue/#findComment-1281762
Share on other sites

Although, this is better because you will probably have more than one input:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xHTML">
    <head>
    <title>Demo</title>
<script type="text/javascript">
function setColor(identification)
{
    document.getElementById(identification).style.background="yellow"
}

function resetColor(identification)
{
    document.getElementById(identification).style.background="white"
}
</script>
</head>
<body>

<form action="">
    <div id="inputDiv_1" style="padding:10px;">
        <input type="" onfocus="setColor('inputDiv_1')" onblur="resetColor('inputDiv_1')" />
    </div>
</form>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/249639-selectors-issue/#findComment-1281766
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.