jquery 'attribute contains' selector with a dynamic value

前端 未结 2 1710
孤街浪徒
孤街浪徒 2021-01-18 03:41

Let\'s say that i have a variable questionId which is an integer, and i want to find tr elements that have the fragment (\"question_\"+questi

2条回答
  •  梦谈多话
    2021-01-18 04:20

    Yep, you almost had it:

    var selector = "tr[id*='quiz_question_" + questionId + "']";
    $(selector)
    

提交回复
热议问题