jQuery& JSF找到< h:inputText/>的特定ID. [英] Jquery & JSF find the particular id for <h:inputText/>

查看:60
本文介绍了jQuery& JSF找到< h:inputText/>的特定ID.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望使用Jquery在JSF中为 inputText 匹配 id .但这不起作用,我也不知道为什么.

I am looking to match id for inputText in JSF using Jquery. But it does not work and I do not know why.

JSF代码

<h:inputText id="email" value="#{userActionManager.newUser.emailID}">
</h:inputText>


jQuery代码


Jquery CODE

$(document).ready(function() {
$("inputText[id^=email]").each(function(){

    this.value = $(this).attr('title');
    $(this).addClass('text-label');

    $(this).focus(function(){
        if(this.value == $(this).attr('title')) {
            this.value = " ";
            $(this).removeClass('text-label');
        }
    });

    $(this).blur(function(){
        if(this.value == '') {
            this.value = $(this).attr('title');
            $(this).addClass('text-label');
        }
    });
});
});

我需要inputText [id ^ = email]才能访问JSF代码中使用的inputText id. 请帮助...

I need inputText[id^=email] to be working to acces the inputText id used in JSF code. Please Help...

推荐答案

首先,页面上的ID应该是唯一的.

Firstly Id's on a page should be unique.

下一步,从选择器(It is not a valid jQuery element selector)中删除inputText tag

Next remove the inputText tag from the selector (It is not a valid jQuery element selector)

$("[id^=email]").each(function(){

您还可以将类电子邮件"添加到inputText并使用类选择器:

You can also add class "email" to inputText and use class selector:

$(".email").each(function(){

这篇关于jQuery&amp; JSF找到&lt; h:inputText/&gt;的特定ID.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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