Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

jQuery onChange HTML

Posted on 2015-02-24
1
Medium Priority
?
46 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 1

Accepted Solution

by:
justaphase earned 2000 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

Docker-Compose to Simplify Multi-Container Builds

Our veteran DevOps Author takes you through how to build a multi-container environment, managed with a single utility in order to simplify your deployments.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
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…
Suggested Courses

688 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