css - front-end and back-end interaction issues!
给我你的怀抱
给我你的怀抱 2017-05-16 13:37:51
0
2
888



I am working on a project recently, and there is an image in an h5 page that is dynamically taken from the backend
How to set the width? I initially used num=$("#lf").find("img").length;//all the pictures on the page and then set the scroll width to each picture width *num+80px but found that it was changed After it is converted into jsp, num cannot be obtained at all. How should the width here be handled? Thanks

给我你的怀抱
给我你的怀抱

reply all(2)
Ty80

Does dynamically fetching data from the backend refer to AJAX request data?
I think we need to confirm the following two points:
1. Is the DOM element loaded when setting the width?
2. Is the AJAX request returned when setting the width? AJAX is asynchronous;

某草草

num=$("#lf").find("img").length, the number of pictures
width num+80px, it should be (num+80) + 'px'
still can't be obtained It should be before js loads the picture, that is to say, the code has been executed before the picture comes out. But try using num as the judgment condition. If num > 0, at least one picture has been loaded. This is safer.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template