I want to access the inner div and get it’s value using Javascript.
Would you please help me, I want to get the value of “phone” and insert it into a “list”. I don’t how to loop in all the DIVS and get only the checked one’s below my setup:
<div class="headings_01">
<div class="checkbox_01"><input name="contact_id" id="selectedcontacts" type="checkbox" value="175" style="margin-top:0px;" /></div>
<div class="firstname_01" name="fname">|175|James</div>
<div class="lastname_01" name="lname">James</div>
<div class="group_01">G1</div>
<div class="mobile_nmbr_01" name="phone" id="phone">123456478</div>
</div>
I have tried this and did not success:
function AddContactPhoneNo()
{
var recipientNumber = document.getElementById("phone");
var opt = "<option value='" + recipientNumber.value + "'>" + recipientNumber.value + "</option>"
if (recipientNumber.value != "")
{
$('#selectedOptions').append(opt);
recipientNumber.value = "";
}
}
I think i’m late responser about the udate of my answer but i’m sure if you find even now the solution then it will help you much. You should change your HTML first then write the jQuery code as like following block of code.
HTML
jQuery
Thats all. Very simple.