开发者

How can I find a space character in an <input> using CSS3 selectors?

My way: code

<form>
    <input type="text" value="">
    <input type="submit" value="submit"> type a space and press Submit
</form>

$('form').开发者_StackOverflow社区submit(function(){
    if($('input').val() == ' ') {
        alert($('input').val().length);
    }
   return false;    
});

But I'd like to solve this problem using CSS3 selectors like $('input[value*=" "]')


If you are asking to use CSS3 selector through jquery then $(':input[value*=" "]') should do it.

example: http://www.jsfiddle.net/gaby/cruRd/

If you want to create an actual CSS3 rule in your stylesheet then input[value*=' ']{..} will work, but only for values in the actual attribute (in the source code) and not the value as modified inside the browser..

example: http://www.jsfiddle.net/gaby/VzE9T/


As far as I know, you cannot manipulate data with CSS; it's a formatting language. You don't have variables or functions which help you find something in a string. Use JS instead.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜