I can change Wordpress input element with different name. As for example the following input element:
<input class="wpProQuiz_button" type="button" value="Start Quiz" name="startQuiz">
can be changed with the following jQuery code:
jQuery("input[name='startQuiz']").attr("value", "Start Mock Test");
Question:
How can I do the same for the following with same name input element in Wordpress?
<input type="button" name="next" value="Next" class="wpProQuiz_button wpProQuiz_QuestionButton" style="float: right;">
<input type="button" name="next" value="Quiz-summary" class="wpProQuiz_button wpProQuiz_QuestionButton" style="float: right;">
I have use the following for the above two input element like :
jQuery("input[name='next']").attr("value", "Next");
jQuery("input[name='next']").attr("value", "Test-summary");
But it is not working. How can I do this?
use jQuery selectors:
jQuery("input[name='next']:first-child").val("zzzz"); jQuery("input[name='next']:nth-child(2)").val("qqqqq");
and take in mind "float:right" :)
more examples here: https://api.jquery.com/category/selectors/child-filter-selectors/