I have a parseuri jQuery plugin method that affects the .val() of an input otherwise the element’s .text(). Although this question is general, this specific method parses URLs for example:
// assume text box contains URL like [ http://example.com:80 ]
$('input:text').parseuri().authority; // get the authority of the domain
// or if in a div
$('div#url').parseuri().port; // get the port of the url
How can I call this jQuery method on a standard string without using a selector?
Context
The plugin is my own, based on the jQuery Maintaining Chainability code sample here and it wraps this parseUri 1.2 JavaScript method.
I pasted my initial attempt here:
http://jsfiddle.net/wyPKH/
I was hoping to have a plugin version of the parseUri JavaScript method that can operate on both elements and plain strings in a consistent manner.
Well, if this is plugin that uses jquery objects you still need to have jquery object
So you have to create element, but it is not mandatory to insert it into dom