How to concatenate variable in string in javascript

后端 未结 4 552
死守一世寂寞
死守一世寂寞 2020-12-01 22:48

I am using this

var abc = jQuery(\'#pl_hid_addon_name\').val(); 
alert(abc);

var atLeastOneIsChecked = jQuery(\'input[name=\"addon-\"\'+abc+\']:checked\').         


        
4条回答
  •  栀梦
    栀梦 (楼主)
    2020-12-01 22:52

    I tried some of the proposed above methods. However, no one was useful to me. After looking some information, I found the property attribute in jQuery (prop()). And that one works for me, the code is the following:

    In my JSF file, I had the following code.

    
    
    
    

    JavaScript section:

    function showDialog() { if($([id='formContrato:asignacion']").prop("selected",true).val() == 'X1') { alert("function X1"); }else if($("id='formContrato:asignacion']").prop("selected",true).val() == 'X2'){alert("function X2"); }else{alert("Other function");} }
    

提交回复
热议问题