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

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -