Hello, I have a script which is as follows (not written by me), and would like to get the value of "content" in this case to be displayed on the screen for test purposes, how can I do this?

<script type="text/javascript">
        $(document).ready(function (){          
            var content = $('#menu-upper').html();          
            $('#menu-upper').html('');
            $('#menu-lower').html(content);
        });
</script>

Recommended Answers

All 4 Replies

Member Avatar for LastMitch

Hello, I have a script which is as follows (not written by me), and would like to get the value of "content" in this case to be displayed on the screen for test purposes, how can I do this?

Where did you get this code? I mean I hope you know that what you mention doesn't make sense:

get the value of "content" in this case to be displayed on the screen for test purposes

<script type="text/javascript">
$(document).ready(function (){
var content = $('#menu-upper').html();
$('#menu-upper').html('');
$('#menu-lower').html(content);
});
</script>

Can you explain to me what is #menu-upper and #menu-lower? I assume it is some sort of div container.

So you just want to display data from the tags?

You can try this (your javascript code is this):

<script type="text/javascript">
$(document).ready(function (){
var content = "This is where you data is display";
$('.menu-upper').html(content);
});
</script>

This is the output:

<div class="menu-upper"></div>

i got the code from an old version of a custom-made cms (made by the same person who wrote this code but not present now)

In fact I wanted to know the values being stored in the "content" variable, so that I can remove specific items to for use from it. Yes the menu-upper and lower are div containers having these IDs

Member Avatar for LastMitch

n fact I wanted to know the values being stored in the "content" variable, so that I can remove specific items to for use from it. Yes the menu-upper and lower are div containers having these IDs

I don't know what you are trying to do?

I hope you don't expect someone to debug the code for you.

Since you want to know the content of #menu-upper and #menu-lower

Try this:

<script type="text/javascript">
$(document).ready(function (){
var content = "This is where you data is display";
$('.menu-upper').html(content);
var contents = "This is where you data2 is display";
$('.menu-lower').html(content);
});
</script>

This is the output once you run the code and this is how it looks like:

<div class="menu-upper">This is where you data is display</div>
<div class="menu-lower">This is where you data2 is display</div>

thanks, am somewhat getting to know some more about javascript/jquery syntax, never used them in the past, still learning the ropes...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.