0

要素のラベルを文字列として取得し、その文字列を jquery で警告したいと考えています。以下のコードを書きましたが、[オブジェクト][オブジェクト]の値を取得します。html() と text() も試しましたが、うまくいきませんでした。

 function seatObject(id, label, status, token){
        this.id = id;
        this.label = label; 
        this.status = status;
        this.token = token;
    }

    for (var x = 0; x < 5; x++) {            
      var temp = new seatObject("#" + x, "label" + x, "available", "");
      seats[x] = temp;                        
      $("#" + x).click(function () {
        currentSeat = $(this).attr("id");
        var label = $("label[for="+$(this).attr('id')+"]");
        alert(label);   
      });
    } 

これも私のタグです。

<rect style="fill: #888888;" id="0" width="35.823246" height="35.823246" x="299.87155" y="65.999405" class="seatObj" label="A24"></rect>
4

2 に答える 2

0

Give class to your label since you are using server-side objects.

<label runat="server" id="myLabel" CssClass="myLabelClass"></label>

alert($(".myLabelClass").text());

should work.

于 2013-10-07T12:09:58.313 に答える