English 中文(简体)
如果投入案文含有一个子典,则核对
原标题:Check if an input text contains a substring JQuery-Mobile

I m trying to check if the contain of my input text contains a substring whih is a variable : here s my code :

<script>
    $("#envoi_search").click(function () {

        var contenu = $("#champ").val() ;
        $("#envoi_search").click(function() {
            $("#result").html(  ) ;
            $( #envoi_search ).attr("disabled", "disabled");
            $.ajax({
                type: "POST",
                url: "http://www.edumobile.org/blog/uploads/XML-parsing-data/Data.xml",
                data: "{}",
                cache: false,
                dataType: "xml",
                success: function(data) {
                    $(data).find("Book").each(function () {
                        var temp = $(this).find("name").text() ;
                        if (temp.toLowerCase().contenu > -1) {
                            $("#result").append("<br> Titre : " + temp);
                            $("#result").append("<br> Auteur : " + $(this).find("address").text());
                            $("#result").append("<br> Pays : " + $(this).find("country").text());
                            $( #envoi_search ).attr("disabled", "");
                        }
                    });

                }
            });
        });
    });
</script>

And I don t know why it doesn t work. Do you have Any idea about my problem ? Thanks :)

最佳回答
//buffer element since we use it multiple times
var $envoi_search = $("#envoi_search");

//bind a single click event handler to the element
$envoi_search.click(function () {

    //create a regular expression based on the value of a form input
    var myRegExp = new RegExp($("#champ").val(), "gi");

    $("#result").html(  );

    $envoi_search.attr("disabled", "disabled");

    $.ajax({
        type     : "POST",
        url      : "http://www.edumobile.org/blog/uploads/XML-parsing-data/Data.xml",
        cache    : false,
        dataType : "xml",
        success  : function(data) {
            $(data).find("Book").each(function () {
                var temp = $(this).find("name").text();

                            //use `.search()` to test the regular expression against a string
                if (temp.toLowerCase().search(myRegExp) > -1) {

                                    //it s a waste to do multiple selections and appends in a row, instead just append everything at once
                    $("#result").append("<br> Titre : " + temp + "<br> Auteur : " + $(this).find("address").text() + "<br> Pays : " + $(this).find("country").text());
                    $envoi_search.attr("disabled", "");
                }
            });

        }
    });
});

我认为,这是你回顾的。 我删除了内联网<代码>。 具有约束力的活动基本上是在活动手里为同一活动举办一个具有约束力的活动,使你不得不两次点击,使内部活动手工作。

另外,如果你不在<编码>www.edumobile.org的相同领域。 然后,你需要用服务器边的语言书写代理文字,以便你能够在没有交叉政策问题的情况下收集数据。

当你检查一下在座标内是否存在扼杀物时,你就失去了<条码>。

var myRegExp = new RegExp($("#champ").val(), "gi");

这根据<代码>#champ输入值形成定期表述。 The gi” states are:

-> global (not real necessary since we reître a .search(,但这可能非常有用)

- &;忽视案件

ya的一些文件:

.search(): https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String/search RegExp(): https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/RegExp `

问题回答

暂无回答




相关问题
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: &...

热门标签