使用jquery删除子项

时间:2017-11-23 09:10:39

标签: jquery jquery-ui

我有什么:

    INSERT INTO Author (Author_ID, Author_FName, Author_LName)
    VALUES  (1, 'Tolkien', 'J.R.R.'),
            (2, 'Robert', 'Ludlum'),
            (3, 'Machado', 'de Assis'),
            (4, 'Jean-Yves', 'Ferri');

我需要什么:

<div class="draggable ui-draggable ui-draggable-handle" name="text" id="created_at" style="opacity: 1;"><i class="fa fa-globe" aria-hidden="true"></i>created_at</div>

我尝试了什么:

<div class="draggable ui-draggable ui-draggable-handle" name="text" id="created_at" style="opacity: 1;">created_at</div>

删除i标签以及旁边的文字。

修改

放入容器后,我想从div标签中删除i。

3 个答案:

答案 0 :(得分:1)

我不认为这会是一个问题,见下文

&#13;
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" rel="stylesheet" />
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />


<p>Drag icons to the DROP ZONE to filter out icons</p>


<div class="drag-item" name="text" id="created_at"><i class="fa fa-globe" aria-hidden="true"></i>created_at</div>
<div class="drag-item" name="text" id="created_at"><i class="fa fa-map" aria-hidden="true"></i>updated_at</div>
<div class="drag-item" name="text" id="created_at"><i class="fa fa-pencil" aria-hidden="true"></i>created_at</div>
<div class="drag-item" name="text" id="created_at"><i class="fa fa-trash" aria-hidden="true"></i>created_at</div>

<div class="area-drop">
  DROP ZONE
</div>
&#13;
.flex-box{
  height:200px;
  overflow-y: hidden;
}

img {
    width: 300px;
    border: 0;
}
&#13;
from keras.applications.vgg16 import VGG16
from keras.preprocessing.image import load_img
from keras.preprocessing.image import img_to_array
from keras.applications.vgg16 import preprocess_input
from keras.applications.vgg16 import decode_predictions

model = VGG16()

print(model.summary())


# load an image from file
image = load_img('./pictures/door.jpg', target_size=(224, 224))
image = img_to_array(image)  #output Numpy-array

#4-dimensional: samples, rows, columns, and channels.
image = image.reshape((1, image.shape[0], image.shape[1], image.shape[2]))


# prepare the image for the VGG model. 
image = preprocess_input(image)


# predict the probability across all output classes. 
yhat = model.predict(image)


# convert the probabilities to class labels
label = decode_predictions(yhat)
# retrieve the most likely result, e.g. highest probability
for i in range(0,5):
    label = label[i][i]
    print('%s (%.2f%%)' % (label[1], label[2] * 100))
&#13;
&#13;
&#13;

答案 1 :(得分:0)

您可以执行jQuery('.draggable i').remove();,文本将保留。

答案 2 :(得分:0)

如果修复了父级的 id ,那么您可以执行以下操作: -

var elToRemove = $("#created_at").find('i');
if(elToRemove.length){
     elToRemove.remove();
}