Recently, I've been designing a webpage and encountered an issue. I want the text in a specific area to change whenever a user clicks on a link. Below is the code snippet related to the section I want to modify using a JavaScript function.
<div id="banner_left">
<h2 id="tagmain">This section contains a title that needs to be updated</h2>
<p id="tagtext">The main body of text that should change dynamically upon clicking a link.</p>
<div class="cleaner_h20"></div>
<div class="button_01"><a href="#">More</a></div>
</div>
The following code relates to the link:
<div class="banner_button">
<a id="support" href="#" onclick="javascript:changeText(args)>Support</a>
</div>
And here's the script for the function:
<script language="javascript" type="text/javascript">
function changeText(idElement) {
if(idElement==1){
document.getElementById.('tagmain').innerHTML ='New title to display';
document.getElementById.('tagtext').innerHTML ='New text to display.';}
return false;
}</script>
I plan to add more conditions to the function to refine its behavior. However, being more familiar with Java than Javascript, I seem to have made an error. Any assistance would be greatly appreciated. My goal is to update the content within the site's body instead of navigating to a new page when a user selects the CSS "button"/link for support. Currently, the function doesn't seem to respond at all. Thank you in advance. Here's hoping it's just a simple fix :)