Solved

jQuery onChange HTML

Posted on 2015-02-24
1
37 Views
Last Modified: 2015-03-07
I have an onChange function.  When a select changes I add a value to a specific div.  Can you pass atuall HTML along with that value?

$( "#result" ).html( premium );
Where premium is can I do something like:
$( "#result" ).html( .'CUSTOM HTML'. premium 'ADDITIONAL CUSTOM HTML.' );
0
Comment
Question by:rgranlund
1 Comment
 
LVL 1

Accepted Solution

by:
justaphase earned 500 total points
ID: 40628856
You can add an onchange event to your select tag id.

HTML:
<select id="selectid">
    <option value="1">One</option>
    <option value="2">Two</option>
</select>

Open in new window


JQuery:
$('#selectid').on('change', function() {
  $( "#result" ).html( 'CUSTOM HTML'+this.value+'ADDITIONAL CUSTOM HTML.' ); //this.value or $(this).val()
});

Open in new window

0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now