Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7184537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:13:20+00:00 2026-05-28T18:13:20+00:00

Using a select dropdown I can replace a main image with the onchange content

  • 0

Using a select dropdown I can replace a main image with the onchange content of value=””

<select name="dropper" id="dropper">
<option value="pl2.jpg" title="pl2.jpg">Design 2</option>
<option value="pl4.jpg" title="pl4.jpg" >Design 4</option>
</select>

<div id="SWAPview"></div>

using

$(document).ready(function() {
$("#dropper").change(function() {
    var src = $(this).val();

    $("#SWAPview").html(src ? "<img src='" + src + "'>" : "");
    });
});

In the live script I can’t use the value=”” so was looking at the title=”” attribute but going around in circles. Any help greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T18:13:21+00:00Added an answer on May 28, 2026 at 6:13 pm

    You can access element property values via prop or attr. As you astutely noticed, the val property no longer works because the select element does not take on the title of the option. Instead you can search its children and filter on the selected using :selected. You will want to get the select option before retrieving this though.

    $("#dropper").change(function() {
        var src = $(this).children('option').filter(':selected').prop('title'); //jquery 1.7+
        var src = $(this).children('option').filter(':selected').attr('title'); //jquery < 1.7
    
        $("#SWAPview img").prop('src', src);
    });
    

    I updated my answer based on this feedback from the jQuery documentation.

    Because :selected is a jQuery extension and not part of the CSS
    specification, queries using :selected cannot take advantage of the
    performance boost provided by the native DOM querySelectorAll()
    method. To achieve the best performance when using :selected to select
    elements, first select the elements using a pure CSS selector, then
    use .filter(“:selected”).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given the following dropdown: <select id=my-dropdown name=my-dropdown> <option value=1>Peter</option> <option value=2 selected>Pan</option> </select> I
The name of a temporary table such as #t1 can be determined using select
For example, mysql quote table name using SELECT * FROM `table_name`; notice the `
I am using the Select->DropDownCheckList from http://dropdown-check-list.googlecode.com/svn/trunk/src/demo.html ... with a PHP back end... This
I want prevent user to select dropdown list items using javascript methods. Is there
I am building a table using the DataGridView where a user can select items
I create a dropdown list by using ASP.NET MVC helper like this, <%=Html.DropDownList(Group,-please select
I have a multi select dropdown list. I can get the array of selected
I have a select dropdown in a html file that i can't really touch
I've written some javascript using jQuery to replace any select lists with a div

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.