Wednesday, April 13, 2011

JQuery index of element

TASK:
Recognize index of element in group on which we clicked.
SOLUTION: 
$("#parent child").index(this);
EXAMPLE:

JQuery
$(document).ready(function() {

    $("#example div").click(function() {
        var index = $("#example div").index(this);
        $("#example_index").html("Index " + index + " was clicked");
    });

});

HTML
<div id="example">
    <div>div index 0</div>
    <div>div index 1</div>
    <div>div index 2</div>
    <div>div index 3</div>
    <div>div index 4</div>
</div>
<div id="example_index">Click one of the above divs</div>

1 comment:

  1. Telemedicine applications are transforming modern healthcare by making medical services more accessible, efficient, and patient-centered. They eliminate geographical barriers, allowing patients to consult doctors from anywhere, anytime. These telemedicine application reduce wait times, lower healthcare costs, and offer convenient features like video calls, e-prescriptions, and health tracking. For providers, they streamline patient management and improve workflow. Overall, telemedicine apps are driving a digital shift toward more responsive and connected healthcare systems.

    ReplyDelete