Klickbare Form-Labels auf iOS Geräten1

var iPadLabels = function () {

	function fix() {
		var labels = document.getElementsByTagName('label'), 
			target_id, 
			el;
		for (var i = 0; labels[i]; i++) {
			if (labels[i].getAttribute('for')) {
				labels[i].onclick = labelClick;
			}
		}
	};

	function labelClick() {
		el = document.getElementById(this.getAttribute('for'));
		if (['radio', 'checkbox'].indexOf(el.getAttribute('type')) != -1) {
			el.setAttribute('selected', !el.getAttribute('selected'));
		} else {
			el.focus();
		}
	};

		return {
		fix: fix
	}

}();

 

  1. http://v4.thewatchmakerproject.com/blog/how-to-fix-the-broken-ipad-form-label-click-issue/ []

Hinterlasse eine Antwort

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind markiert *