How to get input type using jquery?

后端 未结 11 1827
猫巷女王i
猫巷女王i 2020-11-28 02:17

I have a page where the input type always varies, and I need to get the values depending on the input type. So if the type is a radio, I need to get which is checked, and if

11条回答
  •  被撕碎了的回忆
    2020-11-28 02:53

    In my application I ended up with two different elements having the same id (bad). One element was a div and the other an input. I was trying to sum up my inputs and took me a while to realise the duplicate ids. By placing the type of the element I wanted in front of #, I was able to grab the value of the input element and discard the div:

    $("input#_myelementid").val();
    

    I hope it helps.

提交回复
热议问题