javascript - Set two values for span jquery -
i want put 2 values or data span. putting value span this:
$('#spanid').text(data[i].phonenumber);
the code above put phone number span want make in way if data has number mobile number add text if available. put this:
$('#spanid').text(data[i].phonenumber|| data[i].mobilenumber);
but first value set if there value mobile number.
any idea appreciated
do want this
$('#spanid').text((data[i].phonenumber ? data[i].phonenumber +" , " :"") + " " +(data[i].mobilenumber? data[i].mobilenumber :"" ))
and can shorthand second condition
$('#spanid').text((data[i].phonenumber ? data[i].phonenumber +" , " : "") + " " +(data[i].mobilenumber || "" ))
Comments
Post a Comment