The form input item uses label and references the Bootstrap library, which causes the input click effect area to increase.

PHP中文网
Release: 2017-06-07 13:26:01
Original
1675 people have browsed it
产品姐姐想法多,点击input项才能聚焦进行操作,点击外部不能有反应
Copy after login

In order to make labels moresemantic, we often use labels to wrap form items

Copy after login

In the development of mobile platform pages, in order to make the clickable area of form items larger For better operation, label can provide corresponding convenience.

But sometimes, we just need the label, but we don’t want the clickable area to increase for no reason. The introduction ofBootstrapautomatically increases the clickable area

As shown in the picture above, it is only expected that clicking on the input item will have an effect, but clicking on other empty areas within the label label will trigger it (note that clicking on the button will not trigger)

just introduced Bootstrap’s style library

Copy after login

In order to solve it, try to determine theobjecttriggered by theevent. However, it is invalid, it is always theINPUT label, it is unscientific

$('#label-input').click(function(e) {var elem = e.target; console.log(elem.tagName);if (elem.tagName !== 'INPUT') {return false; } })
Copy after login

What can I do? I thought of a way, and then set up a monitor to click the label, and then directly return false

, OK~

$('label').click(function() {return false; }); $('#label-input').click(function(e) {var elem = e.target; console.log(elem.tagName); })
Copy after login

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!