javascript - .replace() is not working like it should -
i trying toggle hidden input element when select element has option. when alerted of variable q, q has no input variable put quite confused why .replace() removes entire string.
function hiddeninput(choice, put) { var q = put.replace(/./g, "").replace(/#/g, ""); alert(put + "," + q);//alerts .other, if (choice === q) { $(put).show(); } else { $(put).hide(); } }
any appreciated. jsfiddle has been quite buggy these past few days of previous working fiddles have stopped working, maybe reason.
do realize .
match character?
you need escape \
match .
, not character.
var q = put.replace(/\./g, "").replace(/#/g, "");
and instead of doing 2 replacements can one
var q = put.replace(/[.#]/g,"");
Comments
Post a Comment