jquery mobile - Javascript change icon -


i try change icon select element. have made 2 values, need 3.

any idea wrong code?

var icon = document.getelementbyid.("marker-icon");      if (type == 1) {           marker-icon.src = "images/icon1.png";     } else if (type == 2) {         marker-icon.src = "images/icon2.png";     } else if (type == 3) {         marker-icon.src = "images/icon3.png"; } 

this code 2 values , works fine.

var icon = (type == 1) ? "images/icon1.png" : "images/icon2.png"; 

try this:

var icon = document.getelementbyid("marker-icon");  if (type == 1) {       icon.src = "images/icon1.png"; } else if (type == 2) {     icon.src = "images/icon2.png"; } else if (type == 3) {     icon.src = "images/icon3.png"; } 

there . after getelementbyid , using marker-icon instead of icon. (i assuming marker-icon id of img tag.)


Popular posts from this blog