lundi 31 août 2015

add class on html tag

I am try to apply a class on HTML tag, if the tag exists.

i try this code...

<!DOCTYPE html>
<html xmlns="http://ift.tt/lH0Osb">
<head>
    <title>index</title>

    <style>
        .black
        {
            background:#000;
            color:white;
        }

    </style>
    <script type="text/javascript">
        $(window).load(function () {
            $('textarea').addClass('black');
        });
    </script>
</head>
<body>

    <div>


        <textarea>content</textarea>


    </div>

    <script src="jquery.js"></script>

</body>
</html>

What i want: If the html body contain textarea tag the the .black class will apply on it automaticly.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire