Jquery Data attribute selector not working
<p>I have this element </p>

<pre><code>&lt;div class="messages selected" data-conversationId=""&gt;&lt;/div&gt;
</code></pre>

<p>The <code>data-attribute</code> <code>conversationId</code> is set dynamically like so:</p>

<pre><code>$(".messages").data("conversationId", conversationId);
</code></pre>

<p>I am having issues using a selector to select this element by the data attribute.</p>

<pre><code>$(".messages[data-conversationId=4]")
</code></pre>

<p>Returns empty array. Interestingly: </p>

<pre><code>$(".messages").data("conversationId")
</code></pre>

<p>returns <code>4</code></p>

<p>What is wrong with my selector?</p>