English 中文(简体)
j Query Append/Remove - appends,但不得去除
原标题:jQuery Append/Remove - appends, but no remove
   function addFormReqFields() { // Add * for required fields
        $( form label ).each(function(index) {
            if ($(this).hasClass( required )) {
                $(this).append( <span class="required"> *</span> );
            }
        });
    }   

    $( #oh_CountryDrpDwn ).change(function(){
        var CountryDrpDwn = $( #oh_CountryDrpDwn ).val();
        if (CountryDrpDwn !=  usa )
        {
            $( #oh_ZipLbl ).remove( <span class="required"> *</span> );
        }
        });

我似乎无法做到这一点。

我有一种形式,即最初确定所有要素都带有红色星号。 (第一职能)。

在第二项职能中,我有一个选择领域(oh_CountryDrpDwn),即如果价值不等于《公约》的价值,那么我就希望从标签上删除<代码><span类别=“要求”>*</span>。

但这似乎根本不会触发。

任何见解?

感谢。

最佳回答

Here is the Fiddle

 $( #oh_ZipLbl ).find( span.required ).remove();

Remove takes a selector not HTML, if you change the content to span with class required, that might fix your problem.

问题回答

何塞·维加确实是正确的,但我要补充的是,你应考虑使用附件/单,特别是在这种情况下,你可能需要重新提出这一内容。 这基本上意味着,这个要素是“移走”,但并非“des”,因此,你可以随意重新加入,无需重新提出。

$(".required").detach();

http://www.bennadel.com/blog/1822-Learning-jQuery-1-4-Remove-vs-Detach-.htm

Edited:

我最初的想法是,需要告诉哪里你发现你最初附在的内容。

$(this).find( span.required ).remove();

然而,我不是专家,因此,没有保证你能很好地回答!





相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签