Replace a DIV with a HTML File [closed] - javascript

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I have created a horizontal menu with 5 tab options using a ul and 5 li tags that is held inside a div
Below this area, I have also create a separate div (id="content1") that will be used to display the content html files based on the tab options selected.
What I am unsure how to accomplish using both JavaScript and jQuery, how can I through a onlick call, replace the div content1 with the html file content? Say I clicked the tab "features" - would like to replace div id content1 with features.html file content?

This is easy to do using jQuery and load() to load the remote content and apply it to a div.
Lucky you, there's a great tutorial that explains exactly how to do this! :)

Try something like this:
$("#features").click(function(){
$("#content1").load('features.html');
});

Couldn't your retrieve the file contents via AJAX, and then set the contents of the div with .html()?

Related

Replace HTML content between two tokens [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I have HTML content warped in between two tokens:
...<p>[ShowMore]This is <b>my</b> content.[/ShowMore]</p>...
I want to get this HTML between the two tokens and replace it with something more complex... using jQuery.
This solution will be used in CMS web site. The gole is to hide content form user and show it on click. Basically this HTML content will be replaced with a link witch will toggle (show/hide) HTML content on user click.
User can have multiple tokens on single site.
Did you mean replace [ShowMore]This is <b>my</b> content.[/ShowMore] by another text ?

ASP.NET change text with no page refresh on button click [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I've found a couple other threads containing the same questions, but none of them had an understandable answer. I am supposed to make client side changes, but that is only possible in the .ascx file and if for instance i want to call a function to calculate something and then display it with no page refresh that is not possible :( any easy solutions?
With jquery, you can replace the contents of any existing HTML element using the .html() function. For example,
$("#MyDiv").html("Here is the new text.");
Since the function takes HTML as an input, you can even set the style if you want:
$("#MyDiv").html("Here is some text. <DIV class='foo'>Here is some more text in a different style.</DIV>");
You can also add new elements using .append(), like this:
$("#MyDiv").append("<p>Even more text</p>");
To do this upon a button click, you would use the .click() function. So your code would look something like this:
$("#MyButton").click(function() {
$("#MyDiv").html("You just clicked a button!");
});

URL/address bar code to hide a specific div on the webpage [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
It is possible to put some code on a link that when somebody press on the link to send a command to the browser in order to hide a specific div in the link target webpage? Thank you.
if your goal is to have a div hide when the user clicks a link, there's no need to reload the whole page with some fancy querystring. Just call a javascript function when the link is clicked:
<div id='hide-me'>This is the div you want to hide</div>
<a href='#' onclick='hideTheDiv()'>hide something</a>
<script type='text/javascript'>
function hideTheDiv() {
$('#hide-me').hide();
}
</script>
For your info, the href='#' tells HTML not to reload the page or go anywhere. so the page stays where it is. onclick tells HTML to run a javascript function.
Sounds like you've got some learning to do. checkout these resources:
http://www.w3schools.com/jsref/event_onclick.asp (can be applied to an anchor tag too, not just buttons)
http://www.w3schools.com/jquery/jquery_ref_selectors.asp

customize choosing a tag feature [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
So I have an app user can create a tag, and choose a tag to post their stories. Everything works fine, but I want to change the way user choosing a tag to post stories. Right now, user has to scroll through the tag they want(more tags created, more scrolls user has to do)
What I'm trying to do is to display, some main tags I make to be inside box and user to be able click the tag that the tag to be chosen. It would be nice to make a search engine that user can type and the tag to be shown up that user can pick....but this seems too advanced for me now. (if you know how, please let me know)
the above is what I hope mine to be replaced to.
I'm not even sure which code I should touch to make this happen.
views.py?forms.py? or is this javascript?html file?
I think you are searching for Select2, there is a django package called django-select2

Create table dynamically each X seconds loose the css settings using jquery mobile [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have just started using JQueryMobile and built a little app.
This app has one page with a table that i build dynamically using javascript.
This table is being built at the app load and each 10 seconds.
After the table is build with all the rows and other stuff , i add it to a div (data-role=page).
On the first time i use $.mobile.changePage("#WantedPage") , it works fine and has the css design.
But, if i stay one this page and the method of the dynamic build of the table is called it looses all of its design it had before.
I tried already to reload the page also after building this table but it still has the same problem.
Can anyone give me a direction with this issue?
I will be glad to give more info if needed.
Edit:
Each td in the table has a button inside it and i noticed recently that before the re-build of the table with new button , it creates a div that has a span and button in it.
and after the re-build , i have only a button in it.
Just trigger this line after you add dynamic content:
$( ".selector" ).table( "rebuild" );
First time it works because you are adding it to other page. Secone page is not enhanced because it was never active before. As soon as you transit to it jQuery will enhance full page markup, including dynamically added table.
But, when page becomes active, if you add dynamic content, you will need to enhance it manually.
There's another function that can help you, but in this case trigger it on whole page:
$('#pageId').triggerWithin();
On there other hand, if you want to find more about this topic read another related answer.
Working example: http://jsfiddle.net/Gajotres/vds2U/85/

Categories

Resources