javascript - change property disabled in a variable containing html with jquery or js -


i need disable elements of class "gcf_crud" variable.

my wrong code is:

var deftext = ''+ '   <div class="form-group col-md-12">'+ '       <h4 id="minimum-setp">{{title}}</h4>'+ '       <input type="text" class="form-control gcf_crud" id="txtusuari" value="{{data}}"/>'+ '   </div>'; var deftextdisabled = $(deftext).find('.gcf_crud').prop('disabled', true); 

with code i'm obtaining input need original html.

how may right?

regards, seak

your deftextdisabled variable returns input because of .find('.gcf_crud').

but seems need reference (variable) jquery object containing elements. in order that, break down process in steps:

var deftext = '<div class="form-group col-md-12">'              +   '<h4 id="minimum-setp">{{title}}</h4>'              +   '<input type="text" class="form-control gcf_crud" id="txtusuari" value="{{data}}"/>'              + '</div>',      $deftext = $(deftext); // save entire thing here        // now, can disable input  $deftext.find('.gcf_crud').prop('disabled', true);    // , use whole content  $('body').append($deftext);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.1/jquery.min.js"></script>


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -