views:

23

answers:

1

Right so I'm creating a plugin using jquery what I have thus far is this. .

(function ($) {

$.fn.AppCompFunctionality = function () {
    var defaults = {

};

var options = $.extend(defaults, options);
return this.each(function () {

    $(this).click(function () {
        var currentComps = $("#currentComps").get();
        $(currentComps).hide();
 });
 });

 };

 })(jQuery);

now suppose currentComps is a Unordered List that has list items inside say

<ul id="currentComps">
<li id="CompName">
Component Name: 
</li>
 <li id="CompVersion">
 Component Version:
</li>
 </ul>

I want to get the list item with the id say 'CompName' only, how would i retrieve this through a plugin. . going through currentComps as full object i get -

I dont want to be able to select CompName using eq() either I want to be able to select is by its id but through CurrentComps if that makes any sense.

A: 

You can do it a couple of ways:

$("#currentComps").children().each(function () {
  if (this.id == "CompName")
    alert("CompName");
});

or

$("ul#currentComps li#CompName")
Neil
With plugings though I have to 'get' all the array elements using the get method. . dont think it works when i try either of those tecniques.
Calibre2010