Pull-down menu based on bootstrap the reason why the item cannot be selected on the handset side with solutions _javascript tips

Source: Internet
Author: User
Tags button type prev

Bootstrap based on the Drop-down menu in the Computer browser can be used normally, in the mobile browser can pop-up Drop-down list, but can not select the menu items in the list, through their own Baidu to find the reason to bootstrap script file Ontouchstart replaced by Disable-ontouchstart can be resolved, and the replacement cannot be resolved. (Red meter Mobile UC Browser does not support, millet cell phone UC Browser normal, other temporarily not tested)

jquery:v1.11.2

bootstrap:v3.3.4

The following is the foreground page code:

<div class= "Input-group" >
<span class= "Input-group-addon" id= "Sizing-addon2" > This field benefits:</span>
<div class= "Btn-group" >
<button type= "button" class= "btn btn-default dropdown-toggle" id= "Btnfuli" Name= "Btnfuli" data-toggle= "dropdown" "value=" "
aria-expanded=" false ">
Please select this field benefit ... <span class=" caret " ></span>
</button>
<ul class= "Dropdown-menu" id= "Uifuli" role= "menu" >
<li> <a title= ' 1 ' href= ' # ' > local welfare </a></li><li class= ' divider ' ></li>
<li><a Title= ' 2 ' href= ' # ' > Field benefits </a></li><li class= ' divider ' ></li> 
</ul>
< Input id= "Txtfuli" name= "this field benefit"/>
</div>
</div>

The following JS script: (Add click for Drop-down menu item)

Databindfuli:function () {
$ ("#UiFuLi li a"). Bind ("click", Function () {
var $this = $ (this);
var $a = $this. Parent (). Parent (). Prev ()
var t = $this. Text ();
$a. Val ($this. attr (' title '));
$ (' #txtFuLi '). Val ($this. attr (' title '));
$a. Text ($this. text ());
$a. Append ("<span class= ' caret ' >");}

The workaround looks like this:

The following code is not supported by the mobile browser, the following elements specified ID assignment can be resolved ()

$this. Parent (). Parent () prev ()

Adjusted code:

$ ("#drpWorkType li a"). Bind ("click", Function () {
var $this = $ (this);
var $a = $this. Parent (). Prev ()
$ (' #txtWorkType '). Val ($this. attr (' title '));
$ (' #btnWorkType '). Val ($this. attr (' title '));
$ (' #btnWorkType '). Text ($this. text ());
$a. Val ($this. attr (' title '));
$a. Text ($this. text ());
$a. Append ("<span class= ' caret ' >");
});

The above is a small set up to introduce the implementation of the bootstrap based on the Drop-down menu mobile phone can not choose the reason for the choice of items with a solution, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.