2

I need to access two attributes I've assigned to my row in code-behind.

userId and eventId

here is what I have.. and have tried.

function ExportToPbuse() 
{
    var rowCount = GeneralReport.rows.length;
    for (var i = 0; i < rowCount; i++) {
        var userId= GeneralTbl.tbodies.row[i]$(this).attr("userid")
        var eventId= GeneralTbl.tbodies.row[i]$(this).attr("eventid")
        //exportArray add userId and eventId
    }
}

this doesn't work... and I've tried a few other ways, but I'm really not all that familiar with jquery so any suggestions would help greatly..thanks :)

1 Answer 1

3

In jQuery, $ is an ordinary function (but with an unusual name) that can take a selector or a DOM element.

Therefore, you can write $(GeneralTbl.tbodies.row[i]).attr("userid"). (Assuming that GeneralTbl.tbodies.row[i] is a <tr> DOM element)

Sign up to request clarification or add additional context in comments.

3 Comments

I've never seen a selector like $(GeneralTbl.tbodies.row[i]) - I didn't realize you could put plain JS in the selector like that.
@neatlysliced: It isn't a selector - it's a regular DOM element. $(this) in an event handler is exactly the same. api.jquery.com/jQuery
I always had it in my head as a selector - $("body"), but now I see I can do $(document.body)... never realized that. Thanks! +1... it would be interesting to run performance comparisons.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.