Azfar Niaz Azfar Niaz - 6 months ago 15
Javascript Question

How can i apply jquery on all elements with same id attribute?

How can i apply jquery on all elements with same id attribute ?

i want to apply a

focus()
and
blur()
function on a
textarea
elements that have same id?

Answer

First, you should not have more than one element with the same ID.

However, you could do this with CSS classes:

<div>
 <textarea class="Text"></textarea>
 <textarea class="Text"></textarea>
 <textarea class="Text"></textarea>
</div>

<script>
    $(".Text").focus();
    $(".Text").blur();
</script>
Comments