如何在JS中访问S2属性。我尝试了以下代码。在这里,我需要在JS函数中动态更改span内容。
在JS中:
template <typename Type>
void LinkedList<Type>::insert(const Type &item, int position){
if(head == NULL){
ListElement *newElement = new ListElement(item, NULL);
newElement->next = NULL;
head = newElement;
cursor = head;
}else if(position == 0){
if(head->next == NULL){
cursor = head;
}
//Create a new ListElement after the current.
ListElement *newElement = new ListElement(item, NULL);
//Preserve link (if there is one)
if(cursor->next != NULL){
newElement->next = cursor->next;
}
cursor->next = newElement;
cursor = newElement;
}else if(position == -1){
//Add a new element before the current.
ListElement *newElement = new ListElement(item, NULL);
if(head->next == NULL || (cursor == head && cursor != NULL)){
//Special case. There is only one node. Must update head pointer.
newElement->next = head;
head = newElement;
cursor = newElement;
}else{
//Node will be put between two other nodes.
ListElement *iterator = head;
while(iterator->next != cursor){
iterator = iterator->next;
}
newElement->next = iterator->next;
iterator->next = newElement;
cursor = newElement;
}
}//end if line 24
}
在JSP中:
else if(position == 0){
if(head->next == NULL){
cursor = head;
}
//Create a new ListElement after the current.
ListElement *newElement = new ListElement(item, NULL);
//Preserve link (if there is one)
if(cursor->next != NULL){ //LINE 71 LINE 71 LINE 71 LINE 71
newElement->next = cursor->next;
}
但没有任何东西可以展示。任何其他解决方案。