Wednesday, April 13, 2011

JQuery select element at index n

TASK:
Select the element at index n within the matched set.


SOLUTION:
$(".example:eq("+index+")").css("color", "red");

EXAMPLE:
Select element at index 1 and set css property "color" to "red":
JQuery
var index=1;
$(".example:eq("+index+")").css("color", "red");

HTML
<div class="example">div index 0</div>
<div class="example">div index 1</div>
<div class="example">div index 2</div>

1 comment:

  1. In Saudi Arabia telehealth app development is gaining momentum due to strong government support through Vision 2030, which prioritizes healthcare digitization. High smartphone penetration, improved internet infrastructure, and a tech-savvy population further fuel adoption. The COVID-19 pandemic also accelerated the shift toward remote care. Combined with growing demand for accessible, affordable healthcare and support for AI-driven innovation, telehealth apps are rapidly transforming the healthcare landscape across the Kingdom.

    ReplyDelete