[javascript] jQuery ID starts with

I am trying to get all elements with an id starting with some value. Below is my jQuery code. I am trying to use a JavaScript variable when searching for items. But it does not work. What am I missing below? So the id 'value' am searching is the value of the clicked element

$(document).ready(function() {
    $('input[name$="_chkmulti"]').click(function(){
        var value = $(this).val();
        $("td[id^= + value +]").each(function(){
            alert("yes");
        });


    });
});

This question is related to javascript jquery

The answer is


Here you go:

$('td[id^="' + value +'"]')

so if the value is for instance 'foo', then the selector will be 'td[id^="foo"]'.

Note that the quotes are mandatory: [id^="...."].

Source: http://api.jquery.com/attribute-starts-with-selector/