0
<div class="content">
    <table id="Table" style="width: 100%;">
    </table>              
</div>

<button type="button" onclick="add()">Add row</button>


function add() {
$("#Table").append("<tr class=\"tr\">" +
    "<td class=\"col-xs-1\" ><h4><input type=\"text\" placeholder=\"Skriv din Projekt kod här...\"    class=\"form-control Projrkt proj\"/></h4></td>" +
     "<td class=\"col-xs-1\" ><input type=\"text\" maxlength=\"2\" class=\"form-control Timmar\"/></td>" +
    "<td class=\"col-xs-1\" ><input type=\"text\" maxlength=\"2\" class=\"form-control Timmar\"/></td>" +
    "<td class=\"col-xs-1\" ><input type=\"text\" maxlength=\"2\" class=\"form-control Timmar\"/></td>" +
    "<td class=\"col-xs-1\" ><input type=\"text\" maxlength=\"2\" class=\"form-control Timmar\"/></td>" +
    "<td class=\"col-xs-1\" ><input type=\"text\" maxlength=\"2\" class=\"form-control Timmar\"/></td>" +
    "<td class=\"col-xs-1\" ><input type=\"text\" maxlength=\"2\" class=\"form-control Timmar\"/></td>" +
    "<td class=\"col-xs-1\" ><input type=\"text\" maxlength=\"2\" class=\"form-control Timmar\"/></td>" +
    "<td class=\"col-xs-1 tdStatus\"><h4><span \" class=\"lblStatus\"></span></h4></td>" +
    "<td class=\"col-xs-1 btnRaderaProjekt1\"><button type=\"button\" class=\"btn btn-danger btn-xs RaderaProjekt\">Radera</button></td></tr>").trigger("create");
}

$(document).on("click", ".RaderaProjekt", function (e) {
    var x = $(e.target).parent().parent().children("td .Timmar:nth-child(2)").val();
    alert(x);
});

I want the value insde the text box that i chose

8
  • how this related to SharePoint? May 29, 2015 at 0:33
  • This is just simple example to learn how to get value using selector. I have another code witch related to sharepoint list. I will ask it in my another question because your answer wan answer to my question but it wast exactly what i wanted May 29, 2015 at 0:53
  • I think now you will understand me. I want the value insde the textbox that i chose May 29, 2015 at 1:15
  • If I get thede values I will save them to my sharepoint list May 29, 2015 at 1:23
  • Ok cool. I just wanted you to add more details so the question will be on topic and moderators will not mark it as off topic question May 29, 2015 at 1:28

1 Answer 1

1

You can get it like this

$(document).on("click", ".btn", function (e) {
    var x = $('.content > table > tbody > tr:nth-child(2) > td:nth-child(2)').text();
    alert(x);
});

Or you can use

$(document).on("click", ".btn", function (e) {    
    $('.content > table td').each(function(index){
        if(index == 4) alert($(this).text());
    });
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.