为每个在其title属性上包含文本的元素添加一个类

I'm generating content for the title attribute dynamically:

<div class="point_data">
<a href="#" title="<?php the_sub_field('points_description'); ?>"></a>

How to add the class .point-tooltip to each anchor link inside the .points_data div that has text on its title attribute (in other words, which is not empty)?

Use this:

$('.point_data a[title]').addClass('point-tooltip');

If the title can be empty use this:

$('.point_data a[title][title!=""]').addClass('point-tooltip');

attribute-not-equal-selector:

Description: Select elements that either don't have the specified attribute, or do have the specified attribute but not with a certain value.

$(".point_data a[title][title!='']").addClass("point-tooltip");

Try with this...

 $(".point_data").find("a[title]").each(function(){
    var titleval = $(this).attr("title").trim();
    if(titleval.length != 0)
    {
        $(this).attr("class","point-tooltip");
    }
});

See this JSFiddle Link: http://jsfiddle.net/rfb23/1/

In case you want to do this in PHP :

<div class="point_data">
<?php 
$title = the_sub_field('points_description');
if(empty($title)) { ?>
  <a href="#" >BLAA</a>
<?php }
else { ?>
  <a href="#" class="point-tooltip" title="<?php echo $title ?>">BLAA</a>
<?php } ?>