1

Im having a little trouble achieving the following: I want that when an upload field has file.. to deactivate other fields. Children elements are added to a DIV when file exists, so using this code on an html file it works: https://jsfiddle.net/hp1egvo7/5/

Notice the <!-- This block exists only when a file was uploaded*/ -->, thats what it's inserted a file exists.

On my wordpress website it doesn't work because initially those children are not there yet... is there any way to add an event listener so that it keeps waiting for the children to exist?

Î've searched and this code doesn't work as well:

jQuery(document).ready(function($){
$("#fld_7213314_3_file_list").change(function(){
alert("The text has been changed.");
if ( $('#fld_7213314_3_file_list').children().length > 0 ) {
 alert("had file uploaded")
}
});
});
Peter
  • 19
  • 3

1 Answers1

1

Actually i found the solution on another post using the bind althought it's not supported for IE8 and below.

The correct code is:

jQuery(document).ready(function($){
$("#fld_7213314_3_file_list").bind("DOMSubtreeModified",function() {
if ( $('#fld_7213314_3_file_list').children().length > 0 ) {
 $(".bi_1_titular").hide();
}
else {$(".bi_1_titular").show();}
});
});
Peter
  • 19
  • 3