从jQuery迁移到Prototype(代码片段)

时间:2022-11-09 22:26:02

I am using Ruby on Rails 3 and I am migrating from jQuery to Prototype but I am a newbie with the first JavaScript framework so I have some trouble. I would like to write the jQuery version of the following Prototype code:

我正在使用Ruby on Rails 3,我正在从jQuery迁移到Prototype,但我是第一个JavaScript框架的新手,所以我遇到了一些麻烦。我想编写以下Prototype代码的jQuery版本:

  page.select("#test_id").each do |element|
    element.replace( "Test text )
  end

How can I do? What is the code?

我能怎么做?什么是代码?

1 个解决方案

#1


3  

$('#test_id').html('Test text');

or

$('.test_class').each(function(){
    $(this).html('Test text');
});

#1


3  

$('#test_id').html('Test text');

or

$('.test_class').each(function(){
    $(this).html('Test text');
});