For some reason this works:
var oldText = $("#tayke li:eq(" + theIndex + ")" ).text();
But this is not so:
var tayke_li = "#tayke li:eq(" + theIndex + ")" var oldTest = $( tayke_li ).text();
Note: theIndex is an integer.
He works both ways. I redid it and it worked. Check the theIndex variable for changes and scope. Try replacing it with hardcoded 1
adding jQuery version information to the question, and the browser spec would be nice too.
It doesn't matter if you put a comma at the end of the line:
var tayke_li = "#tayke li:eq(" + theIndex + ")"; //<---
I installed a simple example and it works great:
alert($("#tab1").length); var s = "#tab" + String(1); //alerts "1" alert(s); //alerts "#tab1" alert($(s).length); //alerts 1
, theIndex String(). , tayke_li
theIndex
String()
tayke_li
?
JavaScript?
javascript?
http://www.webmasterworld.com/forum91/521.htm
to try
var oldText = $("#tayke li:eq("+parseInt(theIndex)+")").text();
or
var oldText = $("#tayke li").eq(theIndex).text();
Source: https://habr.com/ru/post/1732537/More articles:extended xsd for xml with multiple namespaces - springUsing named pipes in one process - c.htaccess subdomains and shared files - phpИспользование ThreadPoolExecutor и AsyncTask - javaQuestion about request and session with CXF, JAX-RS web service - javaThe most efficient way to draw in silverlight - animationHow to add click event to jstree's asynchronous list (jQuery plugin)? - javascriptWhich behavior is preferable? (Embedding Python) - pythonSetting CTreeCtrl for Partial State - user-interfaceWhen is it appropriate to use accordions? - jqueryAll Articles