var selector = '#Id-value_' + index; var exist = $(selector).exists();
I get an error for this piece of code.My document function is ready
$(document).ready( function() { });
There is no exists() function in jQuery. But you can quickly write one:
exists()
//add a new function to jQuery jQuery.fn.exists = function(){return this.length>0;} //now let test it if ($(selector).exists()) { // Do something }
Based on @ K48's answer, you can also directly check if it exists with $(selector).length .
$(selector).length
var selector = '#Id-value_' + index; if ($(selector).length) { // Do something }
Source: https://habr.com/ru/post/1260567/More articles:https://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1260562/google-drive-api-services-account-view-uploaded-files-to-google-drive-using-java&usg=ALkJrhgG-TvUF9Epw5RigVIfSbWFJO7ezgPrinting a pyramid of symbols - javaMongoose - adding a global method to all models - node.jsWhat is the difference between Angular 2 TS and Angular 2 Dart? - angularZabbix vs grafana vs kibana - kibanaGoogle Drive API Access My Account - javaRails + Postgis: error cannot be disabled table_face_ref_sys - ruby-on-railshow to get file path by file name [c #] - c #https://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1260571/migration-to-play-25-leads-to-this-error-nosuchmethoderror-akkaactorlocalactorrefproviderloglakkaeventloggingadapter&usg=ALkJrhjMkkfCqLiDcK30MR6yvFjdQVOMTQVue js repeats the same component when changing a route - javascriptAll Articles