each()函数更新具有相同值的所有元素

时间:2018-02-08 11:01:03

标签: jquery each

尝试使此功能正常工作,但它并不适用于每个.travel。每次旅行都有相同的结果

$(".travel").each(function() {
  var land = $(".invisible .land").text();
  $(".land-vorschau").html(land);
});

请帮忙吗?

2 个答案:

答案 0 :(得分:1)

您必须在上下文中使用$(this)

# Python
import pandas as pd

# Pyspark
from pyspark.sql import SparkSession

# Google storage filepath
filepath = 'gs://[PATH]/'

spark_session = SparkSession.builder.getOrCreate()

sdf = spark_session.createDataFrame([[1],[2],[3],[4],[5]], ['col'])
pdf = pd.DataFrame([1,2,3,4,5], columns=['col'])

# Save the pandas dataframe (THIS IS NOT PERFORMED IN MY BUCKET)
pdf.to_pickle(filepath + 'pickle.pkl' )

# Save the spark dataframe (THIS IS PERFORMED IN MY BUCKET)
sdf.write.csv(filepath + 'spark_dataframe.csv')

# read pickle (THIS WORKS BUT ONLY DURING THIS JOB EXECUTION, 
# IT'S NOT ACCESSIBLE BY ME, maybe its in some temporal folder only)
df_read = pd.read_pickle(filepath + 'pickle.pkl' )

答案 1 :(得分:0)

要在后代中进行选择,请使用.find(),如下所示:

$('.travel').each(function(i, e) {
  var land = $(e).find('.invisible .land').text();
  $(e).find('.land-vorschau').html(land);
});