隐藏文本,但不是在标签jQuery中输入 [英] hide text but not input inside a label jquery

查看:84
本文介绍了隐藏文本,但不是在标签jQuery中输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我们正在使用的购物车输出的标签和输入。我不想破解购物车的核心来改变它的输出方式。所以代码是在标签内输入的:

i have a label and input outputted from the shopping cart we are using. i dont want to hack the core of the cart to change the way it outputs. so the code is thus with the input inside the label:

<div id="FormField_29" class="FormField">
    <label for="FormField_29_0"><input type="checkbox" id="FormField_29_0" name="FormField[2][29][0]" value="Yes" class="subscribeBox FormFieldOption"  /> Yes</label>
</div>

我试图在标签中隐藏单词是,但我似乎无法选择它。它不是来自其标签的兄弟姐妹。如果我选择父母没有输入它仍然使整个标签与输入消失。我试了下,它不会选择它,因为dom明智的文本不是真的下一个..我不能使用孤儿,因为它不是一个孤儿是标签的一部分。
我错过了什么?谢谢!

i am trying to hide the word "yes" in the label, but i cant seem to select it. its not a sibling of the input since its a label. and if i select parent not input it still makes the whole label with the input disappear. i tried next and it wont select it, since dom-wise the text isnt really next.. i cant use orphan since its not an orphan being a part of label. what am i missing? thanks!

推荐答案

使用复选框替换标签内容

Replace the labels contents with just the checkbox.

var l = $('label[for=FormField_29_0]');
l.html(l.find('input'));

这篇关于隐藏文本,但不是在标签jQuery中输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆