Magento2 - How to display image inside dropdown? Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?Magento2: How to add block in my payment modulemagento2 drop down custom options price want to changeMagento-2 : Display gender field as radio instead of dropdownMagento 2 : How to Create Product Attribute With All Active Categories DropDownMagento2 Filters custom module dropdown in adminDynamic number of text fields when a value from dropdown is selected in Magento 2 system configuration backendHow to get USA states dropdown list magento2 custom phtmlMagento2: Image Upload with Preview and Delete checkbox in Edit Admin FormHow to display only USA states as a select drop-down in custom phtml in Magento2.2.5?Set default value in customizable option for radiobutton, checkbox, multiselect in magento2
Central Vacuuming: Is it worth it, and how does it compare to normal vacuuming?
Delete free apps from library
Can you force honesty by using the Speak with Dead and Zone of Truth spells together?
Relating to the President and obstruction, were Mueller's conclusions preordained?
Does the Black Tentacles spell do damage twice at the start of turn to an already restrained creature?
Found this skink in my tomato plant bucket. Is he trapped? Or could he leave if he wanted?
What is the origin of 落第?
The Nth Gryphon Number
Weaponising the Grasp-at-a-Distance spell
What is the difference between a "ranged attack" and a "ranged weapon attack"?
Did pre-Columbian Americans know the spherical shape of the Earth?
Why is std::move not [[nodiscard]] in C++20?
GDP with Intermediate Production
How to change the tick of the color bar legend to black
What does it mean that physics no longer uses mechanical models to describe phenomena?
How many time has Arya actually used Needle?
New Order #6: Easter Egg
How can I prevent/balance waiting and turtling as a response to cooldown mechanics
Resize vertical bars (absolute-value symbols)
Why is the change of basis formula counter-intuitive? [See details]
Can an iPhone 7 be made to function as a NFC Tag?
Is openssl rand command cryptographically secure?
One-one communication
In musical terms, what properties are varied by the human voice to produce different words / syllables?
Magento2 - How to display image inside dropdown?
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?Magento2: How to add block in my payment modulemagento2 drop down custom options price want to changeMagento-2 : Display gender field as radio instead of dropdownMagento 2 : How to Create Product Attribute With All Active Categories DropDownMagento2 Filters custom module dropdown in adminDynamic number of text fields when a value from dropdown is selected in Magento 2 system configuration backendHow to get USA states dropdown list magento2 custom phtmlMagento2: Image Upload with Preview and Delete checkbox in Edit Admin FormHow to display only USA states as a select drop-down in custom phtml in Magento2.2.5?Set default value in customizable option for radiobutton, checkbox, multiselect in magento2
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I want to display image inside drop down option like below image, Can anyone suggest me how can i achieve this?
Any help would be appreciate.
Thanks In Advance..!
magento2 dropdown-options
add a comment |
I want to display image inside drop down option like below image, Can anyone suggest me how can i achieve this?
Any help would be appreciate.
Thanks In Advance..!
magento2 dropdown-options
add a comment |
I want to display image inside drop down option like below image, Can anyone suggest me how can i achieve this?
Any help would be appreciate.
Thanks In Advance..!
magento2 dropdown-options
I want to display image inside drop down option like below image, Can anyone suggest me how can i achieve this?
Any help would be appreciate.
Thanks In Advance..!
magento2 dropdown-options
magento2 dropdown-options
asked 2 days ago
Sanjay GohilSanjay Gohil
546215
546215
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Html Code
<div class="drop-down">
<select name="options">
<option class="en" value="en"
style="background-image:url('images/en.png');">English</option>
<option class="fr" value="fr"
style="background-image:url('images/fr.png');">French</option>
<option class="nl" value="nl"
style="background-image:url('images/nl.png');">Nederlands</option>
</select>
</div>
Jquery
jQuery().ready(function()
/* Custom select design */
jQuery('.drop-down').append('<div class="button"></div>');
jQuery('.drop-down').append('<ul class="select-list"></ul>');
jQuery('.drop-down select option').each(function()
var bg = jQuery(this).css('background-image');
jQuery('.select-list').append('<li class="clsAnchor"><span value="' + jQuery(this).val() + '" class="' + jQuery(this).attr('class') + '" style=background-image:' + bg + '>' + jQuery(this).text() + '</span></li>');
);
jQuery('.drop-down .button').html('<span style=background-image:' + jQuery('.drop-down select').find(':selected').css('background-image') + '>' + jQuery('.drop-down select').find(':selected').text() + '</span>' + '<a href="javascript:void(0);" class="select-list-link">Arrow</a>');
jQuery('.drop-down ul li').each(function()
if (jQuery(this).find('span').text() == jQuery('.drop-down select').find(':selected').text())
jQuery(this).addClass('active');
);
jQuery('.drop-down .select-list span').on('click', function()
var dd_text = jQuery(this).text();
var dd_img = jQuery(this).css('background-image');
var dd_val = jQuery(this).attr('value');
jQuery('.drop-down .button').html('<span style=background-image:' + dd_img + '>' + dd_text + '</span>' + '<a href="javascript:void(0);" class="select-list-link">Arrow</a>');
jQuery('.drop-down .select-list span').parent().removeClass('active');
jQuery(this).parent().addClass('active');
$('.drop-down select[name=options]').val( dd_val );
$('.drop-down .select-list li').slideUp();
);
jQuery('.drop-down .button').on('click','a.select-list-link', function()
jQuery('.drop-down ul li').slideToggle();
);
/* End */
);
Css
.drop-down
position: relative;
display: inline-block;
width: auto;
margin-top: 0;
font-family: verdana;
.drop-down select
display: none;
.drop-down .select-list
position: absolute;
top: 0;
left: 0;
z-index: 1;
margin-top: 40px;
padding: 0;
background-color: #595959;
.drop-down .select-list li
display: none;
.drop-down .select-list li span
display: inline-block;
min-height: 40px;
min-width: 280px;
width: 100%;
padding: 5px 15px 5px 35px;
background-color: #595959;
background-position: left 10px center;
background-repeat: no-repeat;
font-size: 16px;
text-align: left;
color: #FFF;
opacity: 0.7;
box-sizing: border-box;
.drop-down .select-list li span:hover,
.drop-down .select-list li span:focus
opacity: 1;
Result
Refrence: https://www.quora.com/How-can-I-insert-images-to-select-dropdown-options
i have tried it, it works for me. Do you share your screenshot, what error it gives you?
– abdus
2 days ago
Let me try I will notify you, if answer helpful I will accept and also upvote
– Sanjay Gohil
2 days ago
sure, let me know if it works.
– abdus
2 days ago
After spending the hour I found that your solution is work for me..! Thanks +1 for you
– Sanjay Gohil
yesterday
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f270620%2fmagento2-how-to-display-image-inside-dropdown%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Html Code
<div class="drop-down">
<select name="options">
<option class="en" value="en"
style="background-image:url('images/en.png');">English</option>
<option class="fr" value="fr"
style="background-image:url('images/fr.png');">French</option>
<option class="nl" value="nl"
style="background-image:url('images/nl.png');">Nederlands</option>
</select>
</div>
Jquery
jQuery().ready(function()
/* Custom select design */
jQuery('.drop-down').append('<div class="button"></div>');
jQuery('.drop-down').append('<ul class="select-list"></ul>');
jQuery('.drop-down select option').each(function()
var bg = jQuery(this).css('background-image');
jQuery('.select-list').append('<li class="clsAnchor"><span value="' + jQuery(this).val() + '" class="' + jQuery(this).attr('class') + '" style=background-image:' + bg + '>' + jQuery(this).text() + '</span></li>');
);
jQuery('.drop-down .button').html('<span style=background-image:' + jQuery('.drop-down select').find(':selected').css('background-image') + '>' + jQuery('.drop-down select').find(':selected').text() + '</span>' + '<a href="javascript:void(0);" class="select-list-link">Arrow</a>');
jQuery('.drop-down ul li').each(function()
if (jQuery(this).find('span').text() == jQuery('.drop-down select').find(':selected').text())
jQuery(this).addClass('active');
);
jQuery('.drop-down .select-list span').on('click', function()
var dd_text = jQuery(this).text();
var dd_img = jQuery(this).css('background-image');
var dd_val = jQuery(this).attr('value');
jQuery('.drop-down .button').html('<span style=background-image:' + dd_img + '>' + dd_text + '</span>' + '<a href="javascript:void(0);" class="select-list-link">Arrow</a>');
jQuery('.drop-down .select-list span').parent().removeClass('active');
jQuery(this).parent().addClass('active');
$('.drop-down select[name=options]').val( dd_val );
$('.drop-down .select-list li').slideUp();
);
jQuery('.drop-down .button').on('click','a.select-list-link', function()
jQuery('.drop-down ul li').slideToggle();
);
/* End */
);
Css
.drop-down
position: relative;
display: inline-block;
width: auto;
margin-top: 0;
font-family: verdana;
.drop-down select
display: none;
.drop-down .select-list
position: absolute;
top: 0;
left: 0;
z-index: 1;
margin-top: 40px;
padding: 0;
background-color: #595959;
.drop-down .select-list li
display: none;
.drop-down .select-list li span
display: inline-block;
min-height: 40px;
min-width: 280px;
width: 100%;
padding: 5px 15px 5px 35px;
background-color: #595959;
background-position: left 10px center;
background-repeat: no-repeat;
font-size: 16px;
text-align: left;
color: #FFF;
opacity: 0.7;
box-sizing: border-box;
.drop-down .select-list li span:hover,
.drop-down .select-list li span:focus
opacity: 1;
Result
Refrence: https://www.quora.com/How-can-I-insert-images-to-select-dropdown-options
i have tried it, it works for me. Do you share your screenshot, what error it gives you?
– abdus
2 days ago
Let me try I will notify you, if answer helpful I will accept and also upvote
– Sanjay Gohil
2 days ago
sure, let me know if it works.
– abdus
2 days ago
After spending the hour I found that your solution is work for me..! Thanks +1 for you
– Sanjay Gohil
yesterday
add a comment |
Html Code
<div class="drop-down">
<select name="options">
<option class="en" value="en"
style="background-image:url('images/en.png');">English</option>
<option class="fr" value="fr"
style="background-image:url('images/fr.png');">French</option>
<option class="nl" value="nl"
style="background-image:url('images/nl.png');">Nederlands</option>
</select>
</div>
Jquery
jQuery().ready(function()
/* Custom select design */
jQuery('.drop-down').append('<div class="button"></div>');
jQuery('.drop-down').append('<ul class="select-list"></ul>');
jQuery('.drop-down select option').each(function()
var bg = jQuery(this).css('background-image');
jQuery('.select-list').append('<li class="clsAnchor"><span value="' + jQuery(this).val() + '" class="' + jQuery(this).attr('class') + '" style=background-image:' + bg + '>' + jQuery(this).text() + '</span></li>');
);
jQuery('.drop-down .button').html('<span style=background-image:' + jQuery('.drop-down select').find(':selected').css('background-image') + '>' + jQuery('.drop-down select').find(':selected').text() + '</span>' + '<a href="javascript:void(0);" class="select-list-link">Arrow</a>');
jQuery('.drop-down ul li').each(function()
if (jQuery(this).find('span').text() == jQuery('.drop-down select').find(':selected').text())
jQuery(this).addClass('active');
);
jQuery('.drop-down .select-list span').on('click', function()
var dd_text = jQuery(this).text();
var dd_img = jQuery(this).css('background-image');
var dd_val = jQuery(this).attr('value');
jQuery('.drop-down .button').html('<span style=background-image:' + dd_img + '>' + dd_text + '</span>' + '<a href="javascript:void(0);" class="select-list-link">Arrow</a>');
jQuery('.drop-down .select-list span').parent().removeClass('active');
jQuery(this).parent().addClass('active');
$('.drop-down select[name=options]').val( dd_val );
$('.drop-down .select-list li').slideUp();
);
jQuery('.drop-down .button').on('click','a.select-list-link', function()
jQuery('.drop-down ul li').slideToggle();
);
/* End */
);
Css
.drop-down
position: relative;
display: inline-block;
width: auto;
margin-top: 0;
font-family: verdana;
.drop-down select
display: none;
.drop-down .select-list
position: absolute;
top: 0;
left: 0;
z-index: 1;
margin-top: 40px;
padding: 0;
background-color: #595959;
.drop-down .select-list li
display: none;
.drop-down .select-list li span
display: inline-block;
min-height: 40px;
min-width: 280px;
width: 100%;
padding: 5px 15px 5px 35px;
background-color: #595959;
background-position: left 10px center;
background-repeat: no-repeat;
font-size: 16px;
text-align: left;
color: #FFF;
opacity: 0.7;
box-sizing: border-box;
.drop-down .select-list li span:hover,
.drop-down .select-list li span:focus
opacity: 1;
Result
Refrence: https://www.quora.com/How-can-I-insert-images-to-select-dropdown-options
i have tried it, it works for me. Do you share your screenshot, what error it gives you?
– abdus
2 days ago
Let me try I will notify you, if answer helpful I will accept and also upvote
– Sanjay Gohil
2 days ago
sure, let me know if it works.
– abdus
2 days ago
After spending the hour I found that your solution is work for me..! Thanks +1 for you
– Sanjay Gohil
yesterday
add a comment |
Html Code
<div class="drop-down">
<select name="options">
<option class="en" value="en"
style="background-image:url('images/en.png');">English</option>
<option class="fr" value="fr"
style="background-image:url('images/fr.png');">French</option>
<option class="nl" value="nl"
style="background-image:url('images/nl.png');">Nederlands</option>
</select>
</div>
Jquery
jQuery().ready(function()
/* Custom select design */
jQuery('.drop-down').append('<div class="button"></div>');
jQuery('.drop-down').append('<ul class="select-list"></ul>');
jQuery('.drop-down select option').each(function()
var bg = jQuery(this).css('background-image');
jQuery('.select-list').append('<li class="clsAnchor"><span value="' + jQuery(this).val() + '" class="' + jQuery(this).attr('class') + '" style=background-image:' + bg + '>' + jQuery(this).text() + '</span></li>');
);
jQuery('.drop-down .button').html('<span style=background-image:' + jQuery('.drop-down select').find(':selected').css('background-image') + '>' + jQuery('.drop-down select').find(':selected').text() + '</span>' + '<a href="javascript:void(0);" class="select-list-link">Arrow</a>');
jQuery('.drop-down ul li').each(function()
if (jQuery(this).find('span').text() == jQuery('.drop-down select').find(':selected').text())
jQuery(this).addClass('active');
);
jQuery('.drop-down .select-list span').on('click', function()
var dd_text = jQuery(this).text();
var dd_img = jQuery(this).css('background-image');
var dd_val = jQuery(this).attr('value');
jQuery('.drop-down .button').html('<span style=background-image:' + dd_img + '>' + dd_text + '</span>' + '<a href="javascript:void(0);" class="select-list-link">Arrow</a>');
jQuery('.drop-down .select-list span').parent().removeClass('active');
jQuery(this).parent().addClass('active');
$('.drop-down select[name=options]').val( dd_val );
$('.drop-down .select-list li').slideUp();
);
jQuery('.drop-down .button').on('click','a.select-list-link', function()
jQuery('.drop-down ul li').slideToggle();
);
/* End */
);
Css
.drop-down
position: relative;
display: inline-block;
width: auto;
margin-top: 0;
font-family: verdana;
.drop-down select
display: none;
.drop-down .select-list
position: absolute;
top: 0;
left: 0;
z-index: 1;
margin-top: 40px;
padding: 0;
background-color: #595959;
.drop-down .select-list li
display: none;
.drop-down .select-list li span
display: inline-block;
min-height: 40px;
min-width: 280px;
width: 100%;
padding: 5px 15px 5px 35px;
background-color: #595959;
background-position: left 10px center;
background-repeat: no-repeat;
font-size: 16px;
text-align: left;
color: #FFF;
opacity: 0.7;
box-sizing: border-box;
.drop-down .select-list li span:hover,
.drop-down .select-list li span:focus
opacity: 1;
Result
Refrence: https://www.quora.com/How-can-I-insert-images-to-select-dropdown-options
Html Code
<div class="drop-down">
<select name="options">
<option class="en" value="en"
style="background-image:url('images/en.png');">English</option>
<option class="fr" value="fr"
style="background-image:url('images/fr.png');">French</option>
<option class="nl" value="nl"
style="background-image:url('images/nl.png');">Nederlands</option>
</select>
</div>
Jquery
jQuery().ready(function()
/* Custom select design */
jQuery('.drop-down').append('<div class="button"></div>');
jQuery('.drop-down').append('<ul class="select-list"></ul>');
jQuery('.drop-down select option').each(function()
var bg = jQuery(this).css('background-image');
jQuery('.select-list').append('<li class="clsAnchor"><span value="' + jQuery(this).val() + '" class="' + jQuery(this).attr('class') + '" style=background-image:' + bg + '>' + jQuery(this).text() + '</span></li>');
);
jQuery('.drop-down .button').html('<span style=background-image:' + jQuery('.drop-down select').find(':selected').css('background-image') + '>' + jQuery('.drop-down select').find(':selected').text() + '</span>' + '<a href="javascript:void(0);" class="select-list-link">Arrow</a>');
jQuery('.drop-down ul li').each(function()
if (jQuery(this).find('span').text() == jQuery('.drop-down select').find(':selected').text())
jQuery(this).addClass('active');
);
jQuery('.drop-down .select-list span').on('click', function()
var dd_text = jQuery(this).text();
var dd_img = jQuery(this).css('background-image');
var dd_val = jQuery(this).attr('value');
jQuery('.drop-down .button').html('<span style=background-image:' + dd_img + '>' + dd_text + '</span>' + '<a href="javascript:void(0);" class="select-list-link">Arrow</a>');
jQuery('.drop-down .select-list span').parent().removeClass('active');
jQuery(this).parent().addClass('active');
$('.drop-down select[name=options]').val( dd_val );
$('.drop-down .select-list li').slideUp();
);
jQuery('.drop-down .button').on('click','a.select-list-link', function()
jQuery('.drop-down ul li').slideToggle();
);
/* End */
);
Css
.drop-down
position: relative;
display: inline-block;
width: auto;
margin-top: 0;
font-family: verdana;
.drop-down select
display: none;
.drop-down .select-list
position: absolute;
top: 0;
left: 0;
z-index: 1;
margin-top: 40px;
padding: 0;
background-color: #595959;
.drop-down .select-list li
display: none;
.drop-down .select-list li span
display: inline-block;
min-height: 40px;
min-width: 280px;
width: 100%;
padding: 5px 15px 5px 35px;
background-color: #595959;
background-position: left 10px center;
background-repeat: no-repeat;
font-size: 16px;
text-align: left;
color: #FFF;
opacity: 0.7;
box-sizing: border-box;
.drop-down .select-list li span:hover,
.drop-down .select-list li span:focus
opacity: 1;
Result
Refrence: https://www.quora.com/How-can-I-insert-images-to-select-dropdown-options
edited 2 days ago
Ashish Viradiya
1,2421831
1,2421831
answered 2 days ago
abdusabdus
3729
3729
i have tried it, it works for me. Do you share your screenshot, what error it gives you?
– abdus
2 days ago
Let me try I will notify you, if answer helpful I will accept and also upvote
– Sanjay Gohil
2 days ago
sure, let me know if it works.
– abdus
2 days ago
After spending the hour I found that your solution is work for me..! Thanks +1 for you
– Sanjay Gohil
yesterday
add a comment |
i have tried it, it works for me. Do you share your screenshot, what error it gives you?
– abdus
2 days ago
Let me try I will notify you, if answer helpful I will accept and also upvote
– Sanjay Gohil
2 days ago
sure, let me know if it works.
– abdus
2 days ago
After spending the hour I found that your solution is work for me..! Thanks +1 for you
– Sanjay Gohil
yesterday
i have tried it, it works for me. Do you share your screenshot, what error it gives you?
– abdus
2 days ago
i have tried it, it works for me. Do you share your screenshot, what error it gives you?
– abdus
2 days ago
Let me try I will notify you, if answer helpful I will accept and also upvote
– Sanjay Gohil
2 days ago
Let me try I will notify you, if answer helpful I will accept and also upvote
– Sanjay Gohil
2 days ago
sure, let me know if it works.
– abdus
2 days ago
sure, let me know if it works.
– abdus
2 days ago
After spending the hour I found that your solution is work for me..! Thanks +1 for you
– Sanjay Gohil
yesterday
After spending the hour I found that your solution is work for me..! Thanks +1 for you
– Sanjay Gohil
yesterday
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f270620%2fmagento2-how-to-display-image-inside-dropdown%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown