I want to get the text value of a dropdown. But my identifier changes after every page that refreshes. I would like to know how to get the text value of an identifier that changes after each update using jQuery.
First REFRESH => id = "select2-account-t4-container"Second REFRESH => id = "select2-account-g8-container"
First REFRESH => id = "select2-account-t4-container"
Second REFRESH => id = "select2-account-g8-container"
Etc...
You can use start with a selector ^=like:
^=
$('[id^="select2-account"] option:selected').val(); //value //Or $('[id^="select2-account"] option:selected').text(); Text
This way you will always focus on the static static part in id.
id
html- , . $(el).val() .
$(document).ready(function() { var el = $('#select_el'); //value after page rendering console.log(el.val()); //value after select event el.change(function(){ console.log(el.val()); }); });
Source: https://habr.com/ru/post/1691399/More articles:ANTLR - How to determine which parse tree "best matches" some code - javaLaravel 5.5 sets the size of integer fields in a migration file - laravelIonic 2 Android Build Prod Warning при проверке подписания банды - ionic2Executing a shared object file - javaFailed to process the downloaded files for the analytic name - id and version - v1. Check out documentation on how to develop Python analytics - predixMultiple XML tags in SQL - sqlJQuery hides blank space in div - jqueryTf.extract_image_patches implementation - tensorflowHow to select rows with corresponding fields in MySQL? - mysqlWhere is the external code (unsupported / Eigen / CXX11 / Tensor) for the TensorFlow github: - tensorflowAll Articles