sometimes jQuery isn't always the answer :-)
You can just add a few fines to a common js file in your project
String.prototype.beginsWith = function(t, i) { if (i==false) { return
(t == this.substring(0, t.length)); } else { return (t.toLowerCase()
== this.substring(0, t.length).toLowerCase()); } }
String.prototype.endsWith = function(t, i) { if (i==false) { return (t
== this.substring(this.length - t.length)); } else { return
(t.toLowerCase() == this.substring(this.length -
t.length).toLowerCase()); } }
More: (http://www.ivanuzunov.net/top-10-javascript-stringprototype-
extensions/)
And then you can use those on any object, not just a jQuery object
if( $("#div1").text().beginsWith("Item 1", true) == true ) {
// do something with this <div> that starts with "Item 1"
}
heck, even the "trim" prototype listed on that page
String.prototype.trim = function(){ return this.replace(/^\s+|\s+$/
g,'’); }
makes
var trimmedText = $.trim($("#div1").text());
'cleaner' in that it can be said
var trimmedText = $("#div1").text().trim();
On Oct 15, 1:09 pm, debussy007 <[EMAIL PROTECTED]> wrote:
> Hi,
>
> it would be nice to find these two functionalities in the jQuery
> Utilities/String operations, beside trim().
>
> No ?
> --
> View this message in
> context:http://www.nabble.com/startsWith---endsWith-tp19997960s27240p19997960...
> Sent from the jQuery General Discussion mailing list archive at Nabble.com.