how to assign value of a div to another div
I am new to jquery . I wrote small piece of code
<div id="tablediv"><table><tr><td><h2>Select SalesPerson</h2></td><td id="heading"><h3> Click Here </h3></td></tr>
<tr><td></td><td id="101" class="options">12304</td></tr>
<tr><td></td><td id="102" class="options">12305</td></tr>
<tr><td></td><td id="103" class="options">12306</td></tr>
<tr><td></td><td id="104" class="options">12307</td></tr>
</table></div>
</center>
<div id="imagediv"><img src="" id="photo" alt="No Image Found" width="150" height="150"/></div>
And I used the following jquery code:
$(document).ready(function(){
$('td.options').hide();
$("#heading").click(function(){
$('td.options').toggle();
});
$("td.options").hover(function(){
var imgsrc = $(this).attr('id')+".jpg";
$("#photo").attr('src',imgsrc);
});
$("td.options").click(function(){
// $("td.options").val($("#heading").val);
//alert($('td.options').text());
//alert($(this).parent().attr('id'));
//alert($(this).parents('.class'));
$('td.optiodns').hide();
});
});
Now when I click any on of the options (12304/12305/12306/12307), that value has to replace the content of heading tag. How to do it?
javascript jquery
add a comment |
I am new to jquery . I wrote small piece of code
<div id="tablediv"><table><tr><td><h2>Select SalesPerson</h2></td><td id="heading"><h3> Click Here </h3></td></tr>
<tr><td></td><td id="101" class="options">12304</td></tr>
<tr><td></td><td id="102" class="options">12305</td></tr>
<tr><td></td><td id="103" class="options">12306</td></tr>
<tr><td></td><td id="104" class="options">12307</td></tr>
</table></div>
</center>
<div id="imagediv"><img src="" id="photo" alt="No Image Found" width="150" height="150"/></div>
And I used the following jquery code:
$(document).ready(function(){
$('td.options').hide();
$("#heading").click(function(){
$('td.options').toggle();
});
$("td.options").hover(function(){
var imgsrc = $(this).attr('id')+".jpg";
$("#photo").attr('src',imgsrc);
});
$("td.options").click(function(){
// $("td.options").val($("#heading").val);
//alert($('td.options').text());
//alert($(this).parent().attr('id'));
//alert($(this).parents('.class'));
$('td.optiodns').hide();
});
});
Now when I click any on of the options (12304/12305/12306/12307), that value has to replace the content of heading tag. How to do it?
javascript jquery
add a comment |
I am new to jquery . I wrote small piece of code
<div id="tablediv"><table><tr><td><h2>Select SalesPerson</h2></td><td id="heading"><h3> Click Here </h3></td></tr>
<tr><td></td><td id="101" class="options">12304</td></tr>
<tr><td></td><td id="102" class="options">12305</td></tr>
<tr><td></td><td id="103" class="options">12306</td></tr>
<tr><td></td><td id="104" class="options">12307</td></tr>
</table></div>
</center>
<div id="imagediv"><img src="" id="photo" alt="No Image Found" width="150" height="150"/></div>
And I used the following jquery code:
$(document).ready(function(){
$('td.options').hide();
$("#heading").click(function(){
$('td.options').toggle();
});
$("td.options").hover(function(){
var imgsrc = $(this).attr('id')+".jpg";
$("#photo").attr('src',imgsrc);
});
$("td.options").click(function(){
// $("td.options").val($("#heading").val);
//alert($('td.options').text());
//alert($(this).parent().attr('id'));
//alert($(this).parents('.class'));
$('td.optiodns').hide();
});
});
Now when I click any on of the options (12304/12305/12306/12307), that value has to replace the content of heading tag. How to do it?
javascript jquery
I am new to jquery . I wrote small piece of code
<div id="tablediv"><table><tr><td><h2>Select SalesPerson</h2></td><td id="heading"><h3> Click Here </h3></td></tr>
<tr><td></td><td id="101" class="options">12304</td></tr>
<tr><td></td><td id="102" class="options">12305</td></tr>
<tr><td></td><td id="103" class="options">12306</td></tr>
<tr><td></td><td id="104" class="options">12307</td></tr>
</table></div>
</center>
<div id="imagediv"><img src="" id="photo" alt="No Image Found" width="150" height="150"/></div>
And I used the following jquery code:
$(document).ready(function(){
$('td.options').hide();
$("#heading").click(function(){
$('td.options').toggle();
});
$("td.options").hover(function(){
var imgsrc = $(this).attr('id')+".jpg";
$("#photo").attr('src',imgsrc);
});
$("td.options").click(function(){
// $("td.options").val($("#heading").val);
//alert($('td.options').text());
//alert($(this).parent().attr('id'));
//alert($(this).parents('.class'));
$('td.optiodns').hide();
});
});
Now when I click any on of the options (12304/12305/12306/12307), that value has to replace the content of heading tag. How to do it?
javascript jquery
javascript jquery
edited Dec 4 '11 at 11:34
Shadow Wizard
57.4k19110175
57.4k19110175
asked Dec 4 '11 at 11:26
RAVITEJA SATYAVADARAVITEJA SATYAVADA
1,247164378
1,247164378
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You guess you are looking for the html
function:
$("#heading").click(function() {
$('td.options').toggle();
});
$("td.options").hover(function() {
var imgsrc = $(this).attr('id')+".jpg";
$("#photo").attr('src',imgsrc);
});
$("td.options").click(function() {
$("#heading").html($(this).html());
$('td.optiodns').hide();
});
You can read about the text()
and html()
functions here jquery api - html
1
Just insert$(this).hide()
after thehtml()
call and also remove your$('td.optiodns').hide()
call. note you have also misspelledoptions
in your hide call.
– Cyclonecode
Dec 4 '11 at 11:41
Thank you very much...
– RAVITEJA SATYAVADA
Dec 4 '11 at 11:44
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f8374955%2fhow-to-assign-value-of-a-div-to-another-div%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You guess you are looking for the html
function:
$("#heading").click(function() {
$('td.options').toggle();
});
$("td.options").hover(function() {
var imgsrc = $(this).attr('id')+".jpg";
$("#photo").attr('src',imgsrc);
});
$("td.options").click(function() {
$("#heading").html($(this).html());
$('td.optiodns').hide();
});
You can read about the text()
and html()
functions here jquery api - html
1
Just insert$(this).hide()
after thehtml()
call and also remove your$('td.optiodns').hide()
call. note you have also misspelledoptions
in your hide call.
– Cyclonecode
Dec 4 '11 at 11:41
Thank you very much...
– RAVITEJA SATYAVADA
Dec 4 '11 at 11:44
add a comment |
You guess you are looking for the html
function:
$("#heading").click(function() {
$('td.options').toggle();
});
$("td.options").hover(function() {
var imgsrc = $(this).attr('id')+".jpg";
$("#photo").attr('src',imgsrc);
});
$("td.options").click(function() {
$("#heading").html($(this).html());
$('td.optiodns').hide();
});
You can read about the text()
and html()
functions here jquery api - html
1
Just insert$(this).hide()
after thehtml()
call and also remove your$('td.optiodns').hide()
call. note you have also misspelledoptions
in your hide call.
– Cyclonecode
Dec 4 '11 at 11:41
Thank you very much...
– RAVITEJA SATYAVADA
Dec 4 '11 at 11:44
add a comment |
You guess you are looking for the html
function:
$("#heading").click(function() {
$('td.options').toggle();
});
$("td.options").hover(function() {
var imgsrc = $(this).attr('id')+".jpg";
$("#photo").attr('src',imgsrc);
});
$("td.options").click(function() {
$("#heading").html($(this).html());
$('td.optiodns').hide();
});
You can read about the text()
and html()
functions here jquery api - html
You guess you are looking for the html
function:
$("#heading").click(function() {
$('td.options').toggle();
});
$("td.options").hover(function() {
var imgsrc = $(this).attr('id')+".jpg";
$("#photo").attr('src',imgsrc);
});
$("td.options").click(function() {
$("#heading").html($(this).html());
$('td.optiodns').hide();
});
You can read about the text()
and html()
functions here jquery api - html
edited Nov 13 '18 at 9:08
answered Dec 4 '11 at 11:29
CyclonecodeCyclonecode
21.2k95172
21.2k95172
1
Just insert$(this).hide()
after thehtml()
call and also remove your$('td.optiodns').hide()
call. note you have also misspelledoptions
in your hide call.
– Cyclonecode
Dec 4 '11 at 11:41
Thank you very much...
– RAVITEJA SATYAVADA
Dec 4 '11 at 11:44
add a comment |
1
Just insert$(this).hide()
after thehtml()
call and also remove your$('td.optiodns').hide()
call. note you have also misspelledoptions
in your hide call.
– Cyclonecode
Dec 4 '11 at 11:41
Thank you very much...
– RAVITEJA SATYAVADA
Dec 4 '11 at 11:44
1
1
Just insert
$(this).hide()
after the html()
call and also remove your $('td.optiodns').hide()
call. note you have also misspelled options
in your hide call.– Cyclonecode
Dec 4 '11 at 11:41
Just insert
$(this).hide()
after the html()
call and also remove your $('td.optiodns').hide()
call. note you have also misspelled options
in your hide call.– Cyclonecode
Dec 4 '11 at 11:41
Thank you very much...
– RAVITEJA SATYAVADA
Dec 4 '11 at 11:44
Thank you very much...
– RAVITEJA SATYAVADA
Dec 4 '11 at 11:44
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f8374955%2fhow-to-assign-value-of-a-div-to-another-div%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown