Bootstrap tooltip dynamic placement
<p>I'm using Bootstrap tooltip through attribute selector. i.e any element has <code>title</code> attribute should be rendered as a tooltip:</p>

<pre><code>$('[title]').tooltip({placement: 'bottom', trigger: 'hover'});
</code></pre>

<p>However, for some reasons and for some elements I would like to change the placement. Originally, I did not used <code>data-placement</code> attribute for the elements, but for elements that I want its tooltip to have diifirent placement other than the default, I supplied them with <code>data-placement</code> attribute and I modified the above code to be like the following:</p>

<pre><code>$('[title]').tooltip({placement: (typeof $(this).attr('data-placement') === 'undefined')? 'bottom' : $(this).attr('data-placement'), trigger: 'hover'});
</code></pre>

<p>This code should set the placement to be <code>bottom</code> for elements that has no <code>data-placement</code> attribute, while set it equals to its value for elements that has that attribute.</p>

<p>However, the code does not work as expected, it set placement = bottom for every element even,for example, those has <code>data-placement='right</code> </p>