나는 클라이언트의 자동차 프로젝트를 Gari.PK로 개발 중입니다. 그는 내가 드롭 다운을 바꾸기를 원하고 나는 문제에 붙어있다. 다음은 내 HTML 코드 드롭 다운입니다.DropDown 목록에서 HTML로 Jquery Select2에 동적 값을 제공 할 수 없습니다.
<select class="round-10 js-example-basic-single" name="c_version" id="c_version">
<option value="">- Any Version -</option>
<option value="XLi VVTi">XLi VVTi <br><span style="color: red;">2016 . Petrol . Manual</span></option>
<option value="GLi 1.3 VVTi">GLi 1.3 VVTi <br><span style="color: red;">2016 . Petrol . Manual</span></option>
<option value="GLi Automatic 1.3 VVTi">GLi Automatic 1.3 VVTi <br><span style="color: red;">2016 . Petrol . Automatic</span></option>
<option value="Altis Automatic 1.6">Altis Automatic 1.6 <br><span style="color: red;">2016 . Petrol . Automatic</span></option>
<option value="Altis 1.8">Altis 1.8 <br><span style="color: red;">2016 . Petrol . Manual</span></option>
<option value="Altis CVT i 1.8">Altis CVT i 1.8 <br><span style="color: red;">2016 . Petrol . Automatic</span></option>
<option value="Altis Grande 1.8">Altis Grande 1.8 <br><span style="color: red;">2016 . Petrol . Manual</span></option>
<option value="Altis Grande CVT i 1.8">Altis Grande CVT i 1.8 <br><span style="color: red;">2016 . Petrol . Automatic</span></option>
<option value="">Other</option>
</select>
그것은 전면
DropDown list mine and desired
에 다음과 같이 나타나거나 웹 사이트에 http://www.gari.pk/used-cars/sell/를 참조하십시오.
드롭 다운을보다 매력적인 방식으로 변경하려면 이미지의 맨 아래에 표시하고 싶습니다.
하지만 그렇게하지 못했습니다. jQuery select2를 사용하려고하는데 Select2가 'option'태그에서 HTML을 선택하지 않는 것이 문제입니다. 난 당신이 아래에 우리를 선택 2 동적으로 데이터를 제공 할 수있는 말을 몇 가지 게시물을 보았다 :
var data = [
{ id: 0, text: '<div style="color:green">enhancement</div>' },
{ id: 1, text: '<div style="color:red">bug</div><div><small>This is some small text on a new line</small></div>' }];
$(".js-example-basic-single").select2({
data: data,
templateResult: function (d) { return $(d.text); },
templateSelection: function (d) { return $(d.text); },
});
지금 어떻게이 위의 코드에 '옵션'태그에서 데이터를 전달할 수 있습니다.
선택한 플러그인을 사용할 수 있으며 '
좀 더 설명해주십시오. –
https://i.stack.imgur.com/4mOtN.png : 텍스트 상자는 무엇을위한 것입니까? 필터링? [{ 텍스트 : '