Tuesday, 15 April 2014

javascript - Use ID from one page in JQuery -



javascript - Use ID from one page in JQuery -

i have dynamic html in page. want utilize id , info 1 js file other.

i have next html in care.js file

$('#chat-box').html( '<p style="margin-top:10px;">enter name</p><input type="text" id="chat-box-name" class="chat-editing" />' );

now want utilize info entered in above input box in chat.js.

is possible can usethe id/data 1 js file other in same project??

thanks

when code executes have element code child:

<div id="chat-box"> <p style="margin-top:10px;">enter name</p> <input type="text" id="chat-box-name" class="chat-editing" /> </div>

if create sure code sec javascript file gets executed after added content #chat-box can utilize javascript value of inputbox. assuming utilize jquery, did in question:

var input = $('#chat-box-name').val(); //the input

pure javascript:

var input = document.getelementbyid('chat-box-name').value;

javascript jquery html

No comments:

Post a Comment